From 74775b5050176de94bb1a738e0bd93927c639f20 Mon Sep 17 00:00:00 2001 From: rsh-pledra Date: Sat, 20 May 2017 13:48:53 +0530 Subject: [PATCH 01/85] seperate sale order form wizard module added new sale module for same level --- product_configurator_sale/__init__.py | 4 ++ product_configurator_sale/__openerp__.py | 22 +++++++ product_configurator_sale/models/__init__.py | 5 ++ product_configurator_sale/models/account.py | 9 +++ product_configurator_sale/models/sale.py | 56 ++++++++++++++++ product_configurator_sale/models/stock.py | 9 +++ product_configurator_sale/views/sale_view.xml | 66 +++++++++++++++++++ product_configurator_sale/wizard/__init__.py | 1 + .../wizard/product_configurator.py | 62 +++++++++++++++++ 9 files changed, 234 insertions(+) create mode 100755 product_configurator_sale/__init__.py create mode 100755 product_configurator_sale/__openerp__.py create mode 100755 product_configurator_sale/models/__init__.py create mode 100644 product_configurator_sale/models/account.py create mode 100644 product_configurator_sale/models/sale.py create mode 100644 product_configurator_sale/models/stock.py create mode 100644 product_configurator_sale/views/sale_view.xml create mode 100644 product_configurator_sale/wizard/__init__.py create mode 100644 product_configurator_sale/wizard/product_configurator.py diff --git a/product_configurator_sale/__init__.py b/product_configurator_sale/__init__.py new file mode 100755 index 000000000..35e7c9600 --- /dev/null +++ b/product_configurator_sale/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import models +from . import wizard diff --git a/product_configurator_sale/__openerp__.py b/product_configurator_sale/__openerp__.py new file mode 100755 index 000000000..9d81d2ec1 --- /dev/null +++ b/product_configurator_sale/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'Product Configurator Sale', + 'version': '9.0.1.0.0', + 'category': 'Generic Modules/Sale', + 'summary': 'product configuration interface modules for Sale', + 'author': 'Pledra', + 'license': 'AGPL-3', + 'website': 'http://www.pledra.com/', + 'depends': ['sale_stock', 'product_configurator', 'product_configurator_wizard'], + "data": [ + 'views/sale_view.xml', + ], + 'demo': [ + ], + 'images': [ + 'static/description/cover.png' + ], + 'test': [], + 'installable': True, + 'auto_install': False, +} diff --git a/product_configurator_sale/models/__init__.py b/product_configurator_sale/models/__init__.py new file mode 100755 index 000000000..4c439bb9a --- /dev/null +++ b/product_configurator_sale/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +from . import sale +from . import stock +from . import account diff --git a/product_configurator_sale/models/account.py b/product_configurator_sale/models/account.py new file mode 100644 index 000000000..c277de94f --- /dev/null +++ b/product_configurator_sale/models/account.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from openerp import models, fields + + +class AccountInvoiceLine(models.Model): + _inherit = 'account.invoice.line' + + product_id = fields.Many2one(domain=[('config_ok', '=', False)]) diff --git a/product_configurator_sale/models/sale.py b/product_configurator_sale/models/sale.py new file mode 100644 index 000000000..7d0d047c8 --- /dev/null +++ b/product_configurator_sale/models/sale.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +from openerp import models, fields, api + + +# class sale_order_line_attribute(models.Model): +# _name = 'sale.order.line.attribute' + +# custom_value = fields.Char('Custom Value', size=64) +# sale_line_id = fields.Many2one('sale.order.line', 'Sale Order Line') + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + custom_value_ids = fields.One2many( + comodel_name='product.attribute.value.custom', + inverse_name='product_id', + related="product_id.value_custom_ids", + string="Custom Values" + ) + product_id = fields.Many2one(domain=[('config_ok', '=', False)]) + config_ok = fields.Boolean( + related='product_id.config_ok', + string="Configurable" + ) + + @api.multi + def reconfigure_product(self): + """ Creates and launches a product configurator wizard with a linked + template and variant in order to re-configure a existing product. It is + esetially a shortcut to pre-fill configuration data of a variant""" + + cfg_steps = self.product_id.product_tmpl_id.config_step_line_ids + active_step = str(cfg_steps[0].id) if cfg_steps else 'configure' + + wizard_obj = self.env['product.configurator'] + wizard = wizard_obj.create({ + 'product_id': self.product_id.id, + 'state': active_step, + 'order_line_id': self.id, + }) + + return { + 'type': 'ir.actions.act_window', + 'res_model': 'product.configurator', + 'name': "Configure Product", + 'view_mode': 'form', + 'context': dict( + self.env.context, + wizard_id=wizard.id, + ), + 'target': 'new', + 'res_id': wizard.id, + } +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/product_configurator_sale/models/stock.py b/product_configurator_sale/models/stock.py new file mode 100644 index 000000000..de069b9b9 --- /dev/null +++ b/product_configurator_sale/models/stock.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from openerp import models, fields + + +class StockMove(models.Model): + _inherit = 'stock.move' + + product_id = fields.Many2one(domain=[('config_ok', '=', False)]) diff --git a/product_configurator_sale/views/sale_view.xml b/product_configurator_sale/views/sale_view.xml new file mode 100644 index 000000000..e33e21628 --- /dev/null +++ b/product_configurator_sale/views/sale_view.xml @@ -0,0 +1,66 @@ + + + + + + product.configurator.sale.order.line.form.view + sale.order + + + + +
+
+
+ +
+
+ + + + + sale.order.form.config + sale.order + + + +