-
-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
538 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
Sale Option | ||
============== | ||
|
||
This module provide an options system for sale order line. | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
* set bill of material for products which have options | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
* add a sale order line in a sale order | ||
* choose an option | ||
|
||
For further information, please visit: | ||
|
||
* https://www.odoo.com/forum/help-1 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/{project_repo}/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/{project_repo}/issues/new?body=module:%20{module_name}%0Aversion:%20{version}%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Valentin Chemiere <valentin.chemiere@akretion.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import product | ||
from . import sale | ||
from . import mrp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################### | ||
# | ||
# Module for Odoo | ||
# Copyright (C) 2015 Akretion (http://www.akretion.com). | ||
# @author Valentin CHEMIERE <valentin.chemiere@akretion.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################### | ||
|
||
{'name': 'Sale option', | ||
'version': '0.0.1', | ||
'author': 'Akretion', | ||
'website': 'www.akretion.com', | ||
'license': 'AGPL-3', | ||
'category': 'Generic Modules', | ||
'depends': [ | ||
'sale_order_lot_generator', | ||
'sale_order_lot_mrp', | ||
], | ||
'data': [ | ||
'sale_view.xml', | ||
'mrp_view.xml', | ||
'security/ir.model.access.csv', | ||
], | ||
'demo': [ | ||
'demo/product_demo.xml', | ||
], | ||
'installable': True, | ||
'application': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="product_missile_launcher_option" model="product.product"> | ||
<field name="name">Light Missile Launcher</field> | ||
<field name="lst_price" eval="708000"/> | ||
</record> | ||
|
||
<record id="product_shield_extender_option" model="product.product"> | ||
<field name="name">Medium Shield Extender</field> | ||
<field name="lst_price" eval="450000"/> | ||
</record> | ||
|
||
<record id="product_jackdaw_main" model="product.product"> | ||
<field name="name">Jackdaw</field> | ||
<field name="lst_price" eval="34000000"/> | ||
</record> | ||
|
||
<record id="partner_capsuleer" model="res.partner"> | ||
<field name="name">Capsuleer</field> | ||
</record> | ||
|
||
<record id="sale_order_option" model="sale.order"> | ||
<field name="partner_id" eval="ref('sale_option.partner_capsuleer')"/> | ||
<field name="picking_policy" eval="'direct'"/> | ||
</record> | ||
|
||
<record id="sale_order_line_option" model="sale.order.line"> | ||
<field name="order_id" eval="ref('sale_option.sale_order_option')"/> | ||
<field name="product_id" eval="ref('sale_option.product_jackdaw_main')"/> | ||
<field name="price_unit" eval="37732000"/> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################### | ||
# | ||
# Module for Odoo | ||
# Copyright (C) 2015 Akretion (http://www.akretion.com). | ||
# @author Valentin CHEMIERE <valentin.chemiere@akretion.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################### | ||
|
||
from openerp import fields, api, models | ||
|
||
|
||
class BomOption(models.Model): | ||
_name = "mrp.bom.line.option" | ||
|
||
@api.model | ||
def _get_type(self): | ||
selection = ( | ||
('select', 'selection'), | ||
('multiselect', 'multi-selection'), | ||
('required', 'Required'), | ||
) | ||
return selection | ||
|
||
name = fields.Char() | ||
sequence = fields.Integer() | ||
type = fields.Selection('_get_type') | ||
|
||
|
||
class BomLine(models.Model): | ||
_inherit = "mrp.bom.line" | ||
|
||
option_id = fields.Many2one('mrp.bom.line.option', 'Option') | ||
|
||
|
||
class Bom(models.Model): | ||
_inherit = "mrp.bom" | ||
|
||
@api.model | ||
def _skip_bom_line(self, line, product): | ||
res = super(Bom, self)._skip_bom_line(line, product) | ||
prod_id = self.env.context['production_id'] | ||
prod = self.env['mrp.production'].browse(prod_id) | ||
bom_lines = [option.bom_line_id | ||
for option in prod.lot_id.optional_bom_line_ids] | ||
if not line.option_id\ | ||
or line.option_id.type == 'required'\ | ||
or line in bom_lines: | ||
return res | ||
else: | ||
return True | ||
|
||
@api.model | ||
def _prepare_conssumed_line(self, bom_line, quantity, product_uos_qty): | ||
vals = super(Bom, self)._prepare_conssumed_line(bom_line, quantity, product_uos_qty) | ||
prod = self.env['mrp.production'].browse(self.env.context['production_id']) | ||
for option in prod.lot_id.optional_bom_line_ids: | ||
if option.bom_line_id == bom_line: | ||
vals['product_qty'] = vals['product_qty'] * option.qty | ||
return vals | ||
|
||
class StockProductionLot(models.Model): | ||
_inherit = 'stock.production.lot' | ||
|
||
optional_bom_line_ids = fields.Many2many('sale.order.line.option', | ||
'option_lot_rel', | ||
'lot_id', | ||
'option_id', | ||
'optional bom lines') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="view_bom_option_tree" model="ir.ui.view"> | ||
<field name="model">mrp.bom.line.option</field> | ||
<field name="arch" type="xml"> | ||
<tree string="BoM Option"> | ||
<field name="name"/> | ||
<field name="sequence"/> | ||
<field name="type"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="view_bom_option_form" model="ir.ui.view"> | ||
<field name="model">mrp.bom.line.option</field> | ||
<field name="arch" type="xml"> | ||
<form string="BoM Option"> | ||
<sheet> | ||
<group col="6"> | ||
<field name="name" select="1"/> | ||
<field name="sequence"/> | ||
<field name="type"/> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.actions.act_window" id="act_open_bom_option_view"> | ||
<field name="name">BoM Option</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">mrp.bom.line.option</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="domain">[]</field> | ||
<field name="context">{}</field> | ||
</record> | ||
|
||
<record model="ir.actions.act_window.view" id="act_open_bom_option_view_form"> | ||
<field name="act_window_id" ref="act_open_bom_option_view"/> | ||
<field name="sequence" eval="20"/> | ||
<field name="view_mode">form</field> | ||
<field name="view_id" ref="view_bom_option_form"/> | ||
</record> | ||
|
||
<record model="ir.actions.act_window.view" id="act_open_bom_option_view_tree"> | ||
<field name="act_window_id" ref="act_open_bom_option_view"/> | ||
<field name="sequence" eval="10"/> | ||
<field name="view_mode">tree</field> | ||
<field name="view_id" ref="view_bom_option_tree"/> | ||
</record> | ||
|
||
<menuitem id="menu_bom_option" | ||
parent="mrp.menu_mrp_bom" | ||
sequence="20" | ||
action="act_open_bom_option_view"/> | ||
|
||
<record id="view_bom_line_form" model="ir.ui.view"> | ||
<field name="model">mrp.bom</field> | ||
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='bom_line_ids']/tree/field[@name='product_efficiency']" position="after"> | ||
<field name="option_id"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################### | ||
# | ||
# Module for Odoo | ||
# Copyright (C) 2015 Akretion (http://www.akretion.com). | ||
# @author Valentin CHEMIERE <valentin.chemiere@akretion.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################### | ||
|
||
from openerp import fields, api, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
option_ids = fields.Many2many('product.product', relation="product_option", | ||
column1="product_id", column2="option_id", | ||
string="Options") | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
option_for_product_ids = fields.Many2many('product.template', | ||
relation="product_option", | ||
column1="option_id", | ||
column2="product_id", | ||
string="Option for") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
|
||
|
||
<record id="view_product_option_form" model="ir.ui.view"> | ||
<field name="model">product.template</field> | ||
<field name="inherit_id" ref="product.product_template_form_view"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//page[@string='Sales']" position="after"> | ||
<page string="Options" name="option"> | ||
<field name="option_ids" colspan="4" nolabel="1"> | ||
<form> | ||
<group> | ||
<field name="name"/> | ||
<field name="categ_id"/> | ||
</group> | ||
</form> | ||
<tree> | ||
<field name="name"/> | ||
<field name="categ_id"/> | ||
</tree> | ||
</field> | ||
</page> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_product_normal_form_view_option" model="ir.ui.view"> | ||
<field name="model">product.product</field> | ||
<field name="inherit_id" ref="sale_option.view_product_option_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="option_ids" position="after"> | ||
<field name="option_for_product_ids"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
Oops, something went wrong.