Skip to content

Commit

Permalink
Move the changes to main module
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoRubi committed Oct 17, 2018
1 parent 60bc502 commit b79a0ab
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 291 deletions.
81 changes: 63 additions & 18 deletions sale_order_type/README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
===============
Sale Order Type
===============

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

Sales Order Type
================
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/10.0/sale_order_type
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_order_type
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/10.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a typology for the sales orders. In each different type, you
can define, invoicing and refunding journal, a warehouse, a sequence,
can define: invoicing and refunding journal, a warehouse, a sequence,
the shipping policy, the invoicing policy, a payment term, a pricelist
and an incoterm.

Expand All @@ -14,6 +35,22 @@ You can see sale types as lines of business.
You are able to select a sales order type by partner so that when you add a
partner to a sales order it will get the related info to it.

Rules can also be associated with sale order types.

Inside each rule, you can select any number of products and/or product categories.

When editing a sale order that has no type, if a product matches the product of any rule then the sale order type bound to the rule is associated to the sale order.
If the rule does not match *by product*, product categories are checked.

In the sale order form you can also find the matching order type by clicking on the button *Find by rule* placed near the *Type* field.

The sale order types and the rules are inspected based on the value of their *sequence* field.

**Table of contents**

.. contents::
:local:

Configuration
=============

Expand All @@ -28,25 +65,30 @@ Usage
* Go to **Sales > Sales Orders** and create a new sale order. Select the new type you have created before and all settings will be propagated.
* You can also define a type for a particular partner if you go to *Sales & Purchases* and set a sale order type.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/167/10.0


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_type%0Aversion:%20{version}%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_type%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Grupo Vermon
* AvanzOSC
* Tecnativa
* Agile Business Group
* Niboo

Contributors
------------
~~~~~~~~~~~~

* Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
Expand All @@ -57,18 +99,21 @@ Contributors
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Samuel Lefever <sam@niboo.be>
* Pierre Faniel <pierre@niboo.be>
* Simone Rubino <simone.rubino@agilebg.com>

Maintainers
~~~~~~~~~~~

Maintainer
----------
This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/10.0/sale_order_type>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 2 additions & 1 deletion sale_order_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{
"name": "Sale Order Type",
"version": "10.0.1.0.1",
"version": "10.0.1.1.0",
"category": "Sales Management",
"author": "Grupo Vermon,"
"AvanzOSC,"
Expand All @@ -30,6 +30,7 @@
"security/security.xml",
"views/sale_order_view.xml",
"views/sale_order_type_view.xml",
"views/sale_order_type_rule_view.xml",
"views/account_invoice_view.xml",
"views/res_partner_view.xml",
"data/default_type.xml",
Expand Down
1 change: 1 addition & 0 deletions sale_order_type/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import sale_order_type
from . import sale_order_type_rule
from . import sale_order
from . import res_partner
from . import account_invoice
17 changes: 17 additions & 0 deletions sale_order_type/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ def onchange_type_id(self):
if order.type_id.incoterm_id:
order.incoterm = order.type_id.incoterm_id.id

@api.multi
@api.onchange('order_line')
def _onchange_order_line(self):
for order in self:
if not order.type_id:
order.match_order_type()

@api.multi
def match_order_type(self):
order_types = self.env['sale.order.type'].search([])
for order in self:
for order_type in order_types:
if order_type.matches_order(order):
order.type_id = order_type
order.onchange_type_id()
break

@api.model
def create(self, vals):
if vals.get('name', '/') == '/'and vals.get('type_id'):
Expand Down
10 changes: 10 additions & 0 deletions sale_order_type/models/sale_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class SaleOrderTypology(models.Model):
_name = 'sale.order.type'
_description = 'Type of sale order'
_order = 'sequence'

@api.model
def _get_domain_sequence_id(self):
Expand Down Expand Up @@ -41,3 +42,12 @@ def default_picking_policy(self):
payment_term_id = fields.Many2one('account.payment.term', 'Payment Term')
pricelist_id = fields.Many2one('product.pricelist', 'Pricelist')
incoterm_id = fields.Many2one('stock.incoterms', 'Incoterm')
sequence = fields.Integer(default=10)
rule_ids = fields.One2many(
comodel_name='sale.order.type.rule', inverse_name='order_type_id',
copy=True)

@api.multi
def matches_order(self, order):
self.ensure_one()
return any(rule.matches_order(order) for rule in self.rule_ids)
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class SaleOrderTypeRule(models.Model):
def matches_order(self, order):
self.ensure_one()
order_products = order.order_line.mapped('product_id')
if self.product_ids:
return any([
rule_product in order_products
for rule_product in self.product_ids])
if self.product_category_ids:
return any([
rule_category in order_products.mapped('categ_id')
for rule_category in self.product_category_ids])
if self.product_ids and any(
[rule_product in order_products
for rule_product in self.product_ids]):
return True
if self.product_category_ids and any(
[rule_category in order_products.mapped('categ_id')
for rule_category in self.product_category_ids]):
return True
return False
4 changes: 4 additions & 0 deletions sale_order_type/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To configure Sale Order Types you need to:

1. Go to **Sales > Configuration > Sales Orders Types**
2. Create a new sale order type with all the settings you want
10 changes: 10 additions & 0 deletions sale_order_type/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* Carlos Sánchez Cifuentes <csanchez@grupovermon.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <anajuaristi@avanzosc.es>
* Daniel Campos <danielcampos@avanzosc.es>
* Ainara Galdona <ainaragaldona@avanzosc.es>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Samuel Lefever <sam@niboo.be>
* Pierre Faniel <pierre@niboo.be>
* Simone Rubino <simone.rubino@agilebg.com>
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
This module allows the user to define rules in sale order types.
This module adds a typology for the sales orders. In each different type, you
can define: invoicing and refunding journal, a warehouse, a sequence,
the shipping policy, the invoicing policy, a payment term, a pricelist
and an incoterm.

You can see sale types as lines of business.

You are able to select a sales order type by partner so that when you add a
partner to a sales order it will get the related info to it.

Rules can also be associated with sale order types.

Inside each rule, you can select any number of products and/or product categories.

Expand Down
2 changes: 2 additions & 0 deletions sale_order_type/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Go to **Sales > Sales Orders** and create a new sale order. Select the new type you have created before and all settings will be propagated.
* You can also define a type for a particular partner if you go to *Sales & Purchases* and set a sale order type.
3 changes: 3 additions & 0 deletions sale_order_type/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_order_type_manager,access_sale_order_type_manager,model_sale_order_type,sales_team.group_sale_manager,1,1,1,1
access_sale_order_type_salesman,access_sale_order_type_salesman,model_sale_order_type,sales_team.group_sale_salesman,1,0,0,0
access_sale_order_type_account,access_sale_order_type_account,model_sale_order_type,account.group_account_invoice,1,0,0,0
access_sale_order_type_rule_manager,access_sale_order_type_rule_manager,model_sale_order_type_rule,sales_team.group_sale_manager,1,1,1,1
access_sale_order_type_rule_salesman,access_sale_order_type_rule_salesman,model_sale_order_type_rule,sales_team.group_sale_salesman,1,0,0,0
access_sale_order_type_rule_account,access_sale_order_type_rule_account,model_sale_order_type_rule,account.group_account_invoice,1,0,0,0
Loading

0 comments on commit b79a0ab

Please sign in to comment.