From d94176d83f3f1036614495bcf603c6b4acc35e15 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Mon, 15 Oct 2018 14:36:51 +0200 Subject: [PATCH 01/76] [11.0][ADD] sale_elaboration: New module --- sale_elaboration/__init__.py | 2 + sale_elaboration/__manifest__.py | 24 +++ sale_elaboration/i18n/es.po | 160 ++++++++++++++++++ sale_elaboration/models/__init__.py | 4 + sale_elaboration/models/elaboration.py | 35 ++++ sale_elaboration/models/sale_order.py | 65 +++++++ sale_elaboration/models/stock_picking.py | 25 +++ sale_elaboration/readme/CONFIGURE.rst | 4 + sale_elaboration/readme/CONTRIBUTORS.rst | 1 + sale_elaboration/readme/DESCRIPTION.rst | 6 + sale_elaboration/readme/USAGE.rst | 5 + sale_elaboration/security/ir.model.access.csv | 4 + sale_elaboration/static/description/icon.png | Bin 0 -> 9455 bytes sale_elaboration/tests/__init__.py | 2 + .../tests/test_sale_elaboration.py | 89 ++++++++++ .../views/sale_elaboration_report_views.xml | 61 +++++++ .../views/sale_elaboration_views.xml | 59 +++++++ sale_elaboration/views/sale_order_views.xml | 22 +++ 18 files changed, 568 insertions(+) create mode 100644 sale_elaboration/__init__.py create mode 100644 sale_elaboration/__manifest__.py create mode 100644 sale_elaboration/i18n/es.po create mode 100644 sale_elaboration/models/__init__.py create mode 100644 sale_elaboration/models/elaboration.py create mode 100644 sale_elaboration/models/sale_order.py create mode 100644 sale_elaboration/models/stock_picking.py create mode 100644 sale_elaboration/readme/CONFIGURE.rst create mode 100644 sale_elaboration/readme/CONTRIBUTORS.rst create mode 100644 sale_elaboration/readme/DESCRIPTION.rst create mode 100644 sale_elaboration/readme/USAGE.rst create mode 100644 sale_elaboration/security/ir.model.access.csv create mode 100644 sale_elaboration/static/description/icon.png create mode 100644 sale_elaboration/tests/__init__.py create mode 100644 sale_elaboration/tests/test_sale_elaboration.py create mode 100755 sale_elaboration/views/sale_elaboration_report_views.xml create mode 100755 sale_elaboration/views/sale_elaboration_views.xml create mode 100755 sale_elaboration/views/sale_order_views.xml diff --git a/sale_elaboration/__init__.py b/sale_elaboration/__init__.py new file mode 100644 index 00000000000..3275ac2adf3 --- /dev/null +++ b/sale_elaboration/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/sale_elaboration/__manifest__.py b/sale_elaboration/__manifest__.py new file mode 100644 index 00000000000..06c0266c96b --- /dev/null +++ b/sale_elaboration/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Sale Elaboration', + 'summary': 'Set an elaboration for any sale line', + 'version': '11.0.1.0.0', + 'development_status': 'Beta', + 'category': 'Sale', + 'website': 'https://github.com/OCA/sale-workflow', + 'author': 'Tecnativa, Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'auto_install': True, + 'depends': [ + 'sale_stock', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/sale_elaboration_views.xml', + 'views/sale_order_views.xml', + 'views/sale_elaboration_report_views.xml', + ], +} diff --git a/sale_elaboration/i18n/es.po b/sale_elaboration/i18n/es.po new file mode 100644 index 00000000000..9fc118a9adf --- /dev/null +++ b/sale_elaboration/i18n/es.po @@ -0,0 +1,160 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-10-18 11:57+0000\n" +"PO-Revision-Date: 2018-10-18 13:58+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "After Date" +msgstr "" + +#. module: sale_elaboration +#: sql_constraint:product.elaboration:0 +msgid "Code must be unique!" +msgstr "El código debe ser único." + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_date +msgid "Created on" +msgstr "Creado el" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_display_name +msgid "Display Name" +msgstr "Nombre a mostrar" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_elaboration_id +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_search +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "Elaboration" +msgstr "Elaboración" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_elaboration_note +msgid "Elaboration Note" +msgstr "Nota de elaboración" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_form +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_tree +#: model:ir.ui.view,arch_db:sale_elaboration.report_elaboration_view_tree +msgid "Elaborations" +msgstr "Elaboraciones" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_search +msgid "Elaborations Search" +msgstr "Buscar elaboración:" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_id +msgid "ID" +msgstr "ID (identificación)" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_is_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "Is Elaboration" +msgstr "Es elaboración" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration___last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_write_uid +msgid "Last Updated by" +msgstr "Última modificación por" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_name +msgid "Name" +msgstr "Nombre" + +#. module: sale_elaboration +#: sql_constraint:product.elaboration:0 +msgid "Name must be unique!" +msgstr "¡El nombre debe ser único!" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_stock_move_line +msgid "Packing Operation" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_product_id +msgid "Product" +msgstr "Producto" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_sale_order +msgid "Quotation" +msgstr "Presupuesto" + +#. module: sale_elaboration +#: model:ir.actions.act_window,name:sale_elaboration.sale_elaboration_action_form +#: model:ir.ui.menu,name:sale_elaboration.menu_sale_elaboration +msgid "Sale Elaboration" +msgstr "Elaboraciones de venta" + +#. module: sale_elaboration +#: model:ir.actions.act_window,name:sale_elaboration.sale_elaboration_report_action +#: model:ir.ui.menu,name:sale_elaboration.menu_sale_elaboration_report +msgid "Sale Elaboration Report" +msgstr "Informe de elaboraciones" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "Líneas de pedido" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_code +msgid "Short Code" +msgstr "Nombre corto" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_stock_picking +msgid "Transfer" +msgstr "Transferir" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_elaboration +msgid "elaboration" +msgstr "Elaboración" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_product_elaboration +msgid "product.elaboration" +msgstr "Elaboración" diff --git a/sale_elaboration/models/__init__.py b/sale_elaboration/models/__init__.py new file mode 100644 index 00000000000..56d0d0021d9 --- /dev/null +++ b/sale_elaboration/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import elaboration +from . import sale_order +from . import stock_picking diff --git a/sale_elaboration/models/elaboration.py b/sale_elaboration/models/elaboration.py new file mode 100644 index 00000000000..4dcccd19f9f --- /dev/null +++ b/sale_elaboration/models/elaboration.py @@ -0,0 +1,35 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class Elaboration(models.Model): + _name = 'product.elaboration' + + name = fields.Char( + required=True, + ) + code = fields.Char( + string='Short Code', + ) + product_id = fields.Many2one( + comodel_name='product.product', + string='Product', + ondelete='restrict', + ) + + _sql_constraints = [ + ('name_uniq', 'unique(name)', 'Name must be unique!'), + ('code_uniq', 'unique(code)', 'Code must be unique!'), + ] + + @api.model + def name_search(self, name, args=None, operator='ilike', limit=100): + args = args or [] + recs = self.browse() + if name: + recs = self.search([('code', '=', name)] + args, limit=1) + return ( + recs and recs.name_get() or + super().name_search(name, args, operator, limit) + ) diff --git a/sale_elaboration/models/sale_order.py b/sale_elaboration/models/sale_order.py new file mode 100644 index 00000000000..9726f3f3ae6 --- /dev/null +++ b/sale_elaboration/models/sale_order.py @@ -0,0 +1,65 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +def _execute_onchanges(records, field_name): + """Helper methods that executes all onchanges associated to a field.""" + for onchange in records._onchange_methods.get(field_name, []): + for record in records: + record._origin = record.env['sale.order.line'] + onchange(record) + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + def _create_elaboration_line(self, product, qty): + """ + Create a sale order line from a elaboration product, search a line + with the same elaboration product to add qty + :param product: + :param qty: + :return: the sale order line record created + """ + SaleOrderLine = self.env['sale.order.line'] + sol_for_product = self.order_line.filtered( + lambda x: x.product_id == product) + if sol_for_product: + sol_for_product.product_uom_qty += qty + return sol_for_product + sol = SaleOrderLine.new({ + 'order_id': self.id, + 'product_id': product.id, + 'is_elaboration': True, + }) + sol._origin = SaleOrderLine + _execute_onchanges(sol, 'product_id') + sol.update({'product_uom_qty': qty}) + _execute_onchanges(sol, 'product_uom_qty') + vals = sol._convert_to_write(sol._cache) + if self.order_line: + vals['sequence'] = self.order_line[-1].sequence + 1 + sol = SaleOrderLine.sudo().create(vals) + return sol + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + elaboration_id = fields.Many2one( + comodel_name='product.elaboration', + string='Elaboration', + ondelete='restrict', + ) + elaboration_note = fields.Char(string='Elaboration Note') + is_elaboration = fields.Boolean(string='Is Elaboration') + confirmation_date = fields.Datetime( + related='order_id.confirmation_date', + string='Date', + readonly=True, + ) + + @api.onchange('elaboration_id') + def onchange_elaboration_id(self): + self.elaboration_note = self.elaboration_id.name diff --git a/sale_elaboration/models/stock_picking.py b/sale_elaboration/models/stock_picking.py new file mode 100644 index 00000000000..6b58355a1b0 --- /dev/null +++ b/sale_elaboration/models/stock_picking.py @@ -0,0 +1,25 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, models +from collections import defaultdict + + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + @api.multi + def action_done(self): + res = super(StockPicking, self).action_done() + elaboration_product = defaultdict(lambda: 0.0) + for pick in self.filtered(lambda x: x.picking_type_code == 'outgoing'): + elaboration_lines = pick.move_lines.filtered( + lambda x: ( + x.sale_line_id.elaboration_id and + x.sale_line_id.elaboration_id.product_id + )) + for line in elaboration_lines: + product = line.sale_line_id.elaboration_id.product_id + elaboration_product[product] += line.quantity_done + for product, qty in elaboration_product.items(): + pick.sale_id._create_elaboration_line(product, qty) + return res diff --git a/sale_elaboration/readme/CONFIGURE.rst b/sale_elaboration/readme/CONFIGURE.rst new file mode 100644 index 00000000000..ae5951caec4 --- /dev/null +++ b/sale_elaboration/readme/CONFIGURE.rst @@ -0,0 +1,4 @@ +To configure this module you need to: + +#. Go to *Sale > Configuration > Products > Elaboration Sale*. + Create elaborations and a product linked to this. diff --git a/sale_elaboration/readme/CONTRIBUTORS.rst b/sale_elaboration/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..f24a0b0dc74 --- /dev/null +++ b/sale_elaboration/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sergio Teruel diff --git a/sale_elaboration/readme/DESCRIPTION.rst b/sale_elaboration/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..efb9a12c6cc --- /dev/null +++ b/sale_elaboration/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module extends the functionality of sale orders to allow to add an +elaboration in a sale order line and add an extra line with an elaboration +product linked to the elaboration. +An elaboration is a process that needs to be done over the product, usually on +picking/handling phase. It doesn't modify too much the product for needing an +specific product, but it adds a surcharge on the final price. diff --git a/sale_elaboration/readme/USAGE.rst b/sale_elaboration/readme/USAGE.rst new file mode 100644 index 00000000000..a7318257f0b --- /dev/null +++ b/sale_elaboration/readme/USAGE.rst @@ -0,0 +1,5 @@ +#. Go to *Sale > Quotations > Create*. + Create a sales order and select an elaboration in the line. +#. Go to the picking created by this sale order and validate it. +#. Go to *Sales > Quotation*. A new line is created with the product linked to + the elaboration. diff --git a/sale_elaboration/security/ir.model.access.csv b/sale_elaboration/security/ir.model.access.csv new file mode 100644 index 00000000000..a6fe3981cde --- /dev/null +++ b/sale_elaboration/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_elaboration_user,access_elaboration_user,model_product_elaboration,base.group_user,1,0,0,0 +access_elaboration_manager,access_elaboration_manager,model_product_elaboration,sales_team.group_sale_manager,1,1,1,1 +access_elaboration_portal,product.elaboration.portal,model_product_elaboration,base.group_portal,1,0,0,0 diff --git a/sale_elaboration/static/description/icon.png b/sale_elaboration/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q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wmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/sale_elaboration/tests/__init__.py b/sale_elaboration/tests/__init__.py new file mode 100644 index 00000000000..a12476b7878 --- /dev/null +++ b/sale_elaboration/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_sale_elaboration diff --git a/sale_elaboration/tests/test_sale_elaboration.py b/sale_elaboration/tests/test_sale_elaboration.py new file mode 100644 index 00000000000..f01e5d4deaf --- /dev/null +++ b/sale_elaboration/tests/test_sale_elaboration.py @@ -0,0 +1,89 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import SavepointCase + + +class TestSaleElaboration(SavepointCase): + at_install = False + post_install = True + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.Elaboration = cls.env['product.elaboration'] + cls.product = cls.env['product.product'].create({ + 'name': 'test', + }) + cls.product_elaboration_A = cls.env['product.product'].create({ + 'name': 'Product Elaboration A', + 'type': 'service', + 'list_price': 50.0, + }) + cls.product_elaboration_B = cls.env['product.product'].create({ + 'name': 'Product Elaboration B', + 'type': 'service', + 'list_price': 25.0, + }) + cls.partner = cls.env['res.partner'].create({ + 'name': 'test - partner', + }) + cls.elaboration_a = cls.Elaboration.create({ + 'code': 'AA', + 'name': 'Elaboration A', + 'product_id': cls.product_elaboration_A.id, + }) + cls.elaboration_b = cls.Elaboration.create({ + 'code': 'BB', + 'name': 'Elaboration B', + 'product_id': cls.product_elaboration_B.id, + }) + so = cls.env['sale.order'].new({ + 'partner_id': cls.partner.id, + 'order_line': [(0, 0, { + 'name': cls.product.name, + 'product_id': cls.product.id, + 'product_uom_qty': 10.0, + 'product_uom': cls.product.uom_id.id, + 'price_unit': 1000.00, + 'elaboration_id': cls.elaboration_a.id, + 'elaboration_note': 'elaboration A', + })], + }) + so.onchange_partner_id() + cls.order = cls.env['sale.order'].create( + so._convert_to_write(so._cache)) + + def test_search_elaboration(self): + elaboration = self.Elaboration.name_search('Elaboration') + self.assertEqual(len(elaboration), 2) + elaboration = self.Elaboration.name_search('AA') + self.assertEqual(len(elaboration), 1) + + def test_sale_elaboration_change(self): + self.order.order_line.elaboration_id = self.elaboration_b.id + self.order.order_line.onchange_elaboration_id() + self.assertEqual( + self.order.order_line.elaboration_note, 'Elaboration B') + + def test_sale_elaboration(self): + self.order.action_confirm() + self.order.picking_ids.move_lines.quantity_done = 10.0 + self.order.picking_ids.action_done() + elaboration_lines = self.order.order_line.filtered('is_elaboration') + self.assertEqual(len(elaboration_lines), 1) + self.assertEqual(elaboration_lines.price_unit, 50.0) + + def test_sale_elaboration_multi(self): + self.order.order_line.create({ + 'order_id': self.order.id, + 'product_id': self.product_elaboration_A.id, + 'product_uom_qty': 1.0, + 'price_unit': 50.0, + 'is_elaboration': True, + }) + self.order.action_confirm() + self.order.picking_ids.move_lines.quantity_done = 10.0 + self.order.picking_ids.action_done() + elaboration_lines = self.order.order_line.filtered('is_elaboration') + self.assertEqual(len(elaboration_lines), 1) + self.assertEqual(elaboration_lines.product_uom_qty, 11.0) diff --git a/sale_elaboration/views/sale_elaboration_report_views.xml b/sale_elaboration/views/sale_elaboration_report_views.xml new file mode 100755 index 00000000000..030cb7a694a --- /dev/null +++ b/sale_elaboration/views/sale_elaboration_report_views.xml @@ -0,0 +1,61 @@ + + + + + + Elaborations + sale.order.line + + + + + + + + + + + + + + + + sale.order.line + + + + + + + + + + + + + + + + + + Sale Elaboration Report + ir.actions.act_window + sale.order.line + form + tree,pivot + [('state', '=', 'sale')] + {'search_default_is_elaboration':1} + + + + + + diff --git a/sale_elaboration/views/sale_elaboration_views.xml b/sale_elaboration/views/sale_elaboration_views.xml new file mode 100755 index 00000000000..6ede232f302 --- /dev/null +++ b/sale_elaboration/views/sale_elaboration_views.xml @@ -0,0 +1,59 @@ + + + + + + Elaborations + product.elaboration + +
+ + + + + + + +
+
+
+ + + Elaborations + product.elaboration + + + + + + + + + + + Elaborations + product.elaboration + + + + + + + + + + Sale Elaboration + ir.actions.act_window + product.elaboration + form + tree + + + + + +
diff --git a/sale_elaboration/views/sale_order_views.xml b/sale_elaboration/views/sale_order_views.xml new file mode 100755 index 00000000000..d8a97f8756a --- /dev/null +++ b/sale_elaboration/views/sale_order_views.xml @@ -0,0 +1,22 @@ + + + + + + Sale Elaboration + sale.order + + + + + + + + + + + + + + From a89bc6dcb4eca5f412d6bc842ae77fe678e3e445 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Mon, 22 Oct 2018 14:15:43 +0200 Subject: [PATCH 02/76] [11.0][ADD] sale_elaboration: Display elaboration code in picking --- sale_elaboration/__manifest__.py | 1 + .../reports/report_deliveryslip.xml | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 sale_elaboration/reports/report_deliveryslip.xml diff --git a/sale_elaboration/__manifest__.py b/sale_elaboration/__manifest__.py index 06c0266c96b..80b07d15dc9 100644 --- a/sale_elaboration/__manifest__.py +++ b/sale_elaboration/__manifest__.py @@ -20,5 +20,6 @@ 'views/sale_elaboration_views.xml', 'views/sale_order_views.xml', 'views/sale_elaboration_report_views.xml', + 'reports/report_deliveryslip.xml', ], } diff --git a/sale_elaboration/reports/report_deliveryslip.xml b/sale_elaboration/reports/report_deliveryslip.xml new file mode 100755 index 00000000000..4d21ee2d6f6 --- /dev/null +++ b/sale_elaboration/reports/report_deliveryslip.xml @@ -0,0 +1,26 @@ + + + + + + + From 8f1c5baad14385a83bcdfaea71ddb0263a3ad968 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Mon, 29 Oct 2018 16:53:35 +0100 Subject: [PATCH 03/76] [11.0][ADD] sale_elaboration: Display salesman in line views --- sale_elaboration/views/sale_elaboration_report_views.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/sale_elaboration/views/sale_elaboration_report_views.xml b/sale_elaboration/views/sale_elaboration_report_views.xml index 030cb7a694a..a4c13a52eb8 100755 --- a/sale_elaboration/views/sale_elaboration_report_views.xml +++ b/sale_elaboration/views/sale_elaboration_report_views.xml @@ -10,6 +10,7 @@ + From f512b40322f578132115d79493c42f9de7b0100d Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Fri, 1 Feb 2019 10:48:20 +0100 Subject: [PATCH 04/76] [11.0][FIX] sale_elaboration: Get first elaboration product --- sale_elaboration/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sale_elaboration/models/sale_order.py b/sale_elaboration/models/sale_order.py index 9726f3f3ae6..b2a3abd59b3 100644 --- a/sale_elaboration/models/sale_order.py +++ b/sale_elaboration/models/sale_order.py @@ -24,7 +24,7 @@ def _create_elaboration_line(self, product, qty): """ SaleOrderLine = self.env['sale.order.line'] sol_for_product = self.order_line.filtered( - lambda x: x.product_id == product) + lambda x: x.product_id == product)[:1] if sol_for_product: sol_for_product.product_uom_qty += qty return sol_for_product From c57e615548404123e613a846bccb801ac6027d3a Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Tue, 19 Feb 2019 14:21:37 +0100 Subject: [PATCH 05/76] [11.0][IMP] sale_elaboration: Add to invoice line the sale order reference --- sale_elaboration/models/sale_order.py | 7 ++++ .../tests/test_sale_elaboration.py | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/sale_elaboration/models/sale_order.py b/sale_elaboration/models/sale_order.py index b2a3abd59b3..c1066a89c1e 100644 --- a/sale_elaboration/models/sale_order.py +++ b/sale_elaboration/models/sale_order.py @@ -63,3 +63,10 @@ class SaleOrderLine(models.Model): @api.onchange('elaboration_id') def onchange_elaboration_id(self): self.elaboration_note = self.elaboration_id.name + + @api.multi + def _prepare_invoice_line(self, qty): + vals = super()._prepare_invoice_line(qty) + if self.is_elaboration: + vals['name'] = '{} - {}'.format(self.order_id.name, self.name) + return vals diff --git a/sale_elaboration/tests/test_sale_elaboration.py b/sale_elaboration/tests/test_sale_elaboration.py index f01e5d4deaf..7c1192e3322 100644 --- a/sale_elaboration/tests/test_sale_elaboration.py +++ b/sale_elaboration/tests/test_sale_elaboration.py @@ -13,16 +13,19 @@ def setUpClass(cls): cls.Elaboration = cls.env['product.elaboration'] cls.product = cls.env['product.product'].create({ 'name': 'test', + 'tracking': 'none', }) cls.product_elaboration_A = cls.env['product.product'].create({ 'name': 'Product Elaboration A', 'type': 'service', 'list_price': 50.0, + 'invoice_policy': 'order', }) cls.product_elaboration_B = cls.env['product.product'].create({ 'name': 'Product Elaboration B', 'type': 'service', 'list_price': 25.0, + 'invoice_policy': 'order', }) cls.partner = cls.env['res.partner'].create({ 'name': 'test - partner', @@ -87,3 +90,42 @@ def test_sale_elaboration_multi(self): elaboration_lines = self.order.order_line.filtered('is_elaboration') self.assertEqual(len(elaboration_lines), 1) self.assertEqual(elaboration_lines.product_uom_qty, 11.0) + + def test_invoice_elaboration(self): + so = self.env['sale.order'].new({ + 'partner_id': self.partner.id, + 'order_line': [ + (0, 0, { + 'name': self.product_elaboration_A.name, + 'product_id': self.product_elaboration_A.id, + 'product_uom_qty': 1.0, + 'price_unit': 50.0, + 'is_elaboration': True, + }), + (0, 0, { + 'name': self.product_elaboration_B.name, + 'product_id': self.product_elaboration_B.id, + 'product_uom_qty': 1.0, + 'price_unit': 50.0, + 'is_elaboration': False, + }), + ], + }) + so.onchange_partner_id() + self.order = self.env['sale.order'].create( + so._convert_to_write(so._cache)) + self.order.action_confirm() + invoice_id = self.order.action_invoice_create() + invoice = self.env['account.invoice'].browse(invoice_id) + so_line_elaboration = self.order.order_line.filtered('is_elaboration') + so_line_no_elaboration = self.order.order_line - so_line_elaboration + inv_line_elaboration = invoice.invoice_line_ids.filtered( + lambda x: x.sale_line_ids == so_line_elaboration) + inv_line_no_elaboration = invoice.invoice_line_ids.filtered( + lambda x: x.sale_line_ids == so_line_no_elaboration) + self.assertEqual( + inv_line_elaboration.name, + '{} - {}'.format(self.order.name, so_line_elaboration.name)) + self.assertNotEqual( + inv_line_no_elaboration.name, + '{} - {}'.format(self.order.name, so_line_no_elaboration.name)) From 8fee4a60bae46bc5a94713572df176020ad7f1c4 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 28 Feb 2019 18:05:07 +0100 Subject: [PATCH 06/76] [IMP] sale_elaboration: Some improvements --- sale_elaboration/models/__init__.py | 2 +- sale_elaboration/models/elaboration.py | 35 ------------- .../models/product_elaboration.py | 49 +++++++++++++++++++ sale_elaboration/models/sale_order.py | 8 +-- sale_elaboration/models/stock_picking.py | 26 +++++----- sale_elaboration/readme/CONFIGURE.rst | 3 +- sale_elaboration/readme/CONTRIBUTORS.rst | 5 +- sale_elaboration/readme/DESCRIPTION.rst | 13 ++--- sale_elaboration/readme/USAGE.rst | 11 +++-- .../views/sale_elaboration_report_views.xml | 6 ++- sale_elaboration/views/sale_order_views.xml | 3 +- 11 files changed, 93 insertions(+), 68 deletions(-) delete mode 100644 sale_elaboration/models/elaboration.py create mode 100644 sale_elaboration/models/product_elaboration.py diff --git a/sale_elaboration/models/__init__.py b/sale_elaboration/models/__init__.py index 56d0d0021d9..08e036c192d 100644 --- a/sale_elaboration/models/__init__.py +++ b/sale_elaboration/models/__init__.py @@ -1,4 +1,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from . import elaboration +from . import product_elaboration from . import sale_order from . import stock_picking diff --git a/sale_elaboration/models/elaboration.py b/sale_elaboration/models/elaboration.py deleted file mode 100644 index 4dcccd19f9f..00000000000 --- a/sale_elaboration/models/elaboration.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2018 Tecnativa - Sergio Teruel -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import api, fields, models - - -class Elaboration(models.Model): - _name = 'product.elaboration' - - name = fields.Char( - required=True, - ) - code = fields.Char( - string='Short Code', - ) - product_id = fields.Many2one( - comodel_name='product.product', - string='Product', - ondelete='restrict', - ) - - _sql_constraints = [ - ('name_uniq', 'unique(name)', 'Name must be unique!'), - ('code_uniq', 'unique(code)', 'Code must be unique!'), - ] - - @api.model - def name_search(self, name, args=None, operator='ilike', limit=100): - args = args or [] - recs = self.browse() - if name: - recs = self.search([('code', '=', name)] + args, limit=1) - return ( - recs and recs.name_get() or - super().name_search(name, args, operator, limit) - ) diff --git a/sale_elaboration/models/product_elaboration.py b/sale_elaboration/models/product_elaboration.py new file mode 100644 index 00000000000..ec8a2e4fdd9 --- /dev/null +++ b/sale_elaboration/models/product_elaboration.py @@ -0,0 +1,49 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# Copyright 2019 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class Elaboration(models.Model): + _name = 'product.elaboration' + + name = fields.Char( + required=True, + translate=True, + ) + code = fields.Char( + string='Short Code', + ) + product_id = fields.Many2one( + comodel_name='product.product', + string='Product', + ondelete='restrict', + domain=[('type', '=', 'service')], + required=True, + ) + + _sql_constraints = [ + ('name_uniq', 'unique(name)', 'Name must be unique!'), + ('code_uniq', 'unique(code)', 'Code must be unique!'), + ] + + @api.model + def name_search(self, name, args=None, operator='ilike', limit=100): + """Give preference to codes on name search, appending + the rest of the results after. + """ + if not args: + args = [] + recs = self.search([('code', operator, name)] + args, limit=limit) + res = recs.name_get() + if limit: + limit_rest = limit - len(recs) + else: # pragma: no cover + # limit can be 0 or None representing infinite + limit_rest = limit + if limit_rest or not limit: + args += [('id', 'not in', recs.ids)] + res += super().name_search( + name, args=args, operator=operator, limit=limit_rest, + ) + return res diff --git a/sale_elaboration/models/sale_order.py b/sale_elaboration/models/sale_order.py index c1066a89c1e..78fa621cf9d 100644 --- a/sale_elaboration/models/sale_order.py +++ b/sale_elaboration/models/sale_order.py @@ -1,4 +1,5 @@ # Copyright 2018 Tecnativa - Sergio Teruel +# Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models @@ -15,8 +16,7 @@ class SaleOrder(models.Model): _inherit = 'sale.order' def _create_elaboration_line(self, product, qty): - """ - Create a sale order line from a elaboration product, search a line + """Create a sale order line from a elaboration product, search a line with the same elaboration product to add qty :param product: :param qty: @@ -33,6 +33,7 @@ def _create_elaboration_line(self, product, qty): 'product_id': product.id, 'is_elaboration': True, }) + # TODO: Needed? sol._origin = SaleOrderLine _execute_onchanges(sol, 'product_id') sol.update({'product_uom_qty': qty}) @@ -40,8 +41,7 @@ def _create_elaboration_line(self, product, qty): vals = sol._convert_to_write(sol._cache) if self.order_line: vals['sequence'] = self.order_line[-1].sequence + 1 - sol = SaleOrderLine.sudo().create(vals) - return sol + return SaleOrderLine.sudo().create(vals) class SaleOrderLine(models.Model): diff --git a/sale_elaboration/models/stock_picking.py b/sale_elaboration/models/stock_picking.py index 6b58355a1b0..219c69b207c 100644 --- a/sale_elaboration/models/stock_picking.py +++ b/sale_elaboration/models/stock_picking.py @@ -1,7 +1,6 @@ # Copyright 2018 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, models -from collections import defaultdict class StockPicking(models.Model): @@ -10,16 +9,17 @@ class StockPicking(models.Model): @api.multi def action_done(self): res = super(StockPicking, self).action_done() - elaboration_product = defaultdict(lambda: 0.0) - for pick in self.filtered(lambda x: x.picking_type_code == 'outgoing'): - elaboration_lines = pick.move_lines.filtered( - lambda x: ( - x.sale_line_id.elaboration_id and - x.sale_line_id.elaboration_id.product_id - )) - for line in elaboration_lines: - product = line.sale_line_id.elaboration_id.product_id - elaboration_product[product] += line.quantity_done - for product, qty in elaboration_product.items(): - pick.sale_id._create_elaboration_line(product, qty) + with self.env.norecompute(): + for pick in self.filtered( + lambda x: x.picking_type_code == 'outgoing' + ): + elaboration_lines = pick.move_lines.filtered( + lambda x: x.sale_line_id.elaboration_id + ) + for line in elaboration_lines: + pick.sale_id._create_elaboration_line( + line.sale_line_id.elaboration_id.product_id, + line.quantity_done, + ) + self.recompute() return res diff --git a/sale_elaboration/readme/CONFIGURE.rst b/sale_elaboration/readme/CONFIGURE.rst index ae5951caec4..90d19fe4306 100644 --- a/sale_elaboration/readme/CONFIGURE.rst +++ b/sale_elaboration/readme/CONFIGURE.rst @@ -1,4 +1,5 @@ To configure this module you need to: #. Go to *Sale > Configuration > Products > Elaboration Sale*. - Create elaborations and a product linked to this. +#. Create a new record. +#. Set a product linked to the elaboration. diff --git a/sale_elaboration/readme/CONTRIBUTORS.rst b/sale_elaboration/readme/CONTRIBUTORS.rst index f24a0b0dc74..e0ec07be3b8 100644 --- a/sale_elaboration/readme/CONTRIBUTORS.rst +++ b/sale_elaboration/readme/CONTRIBUTORS.rst @@ -1 +1,4 @@ -* Sergio Teruel +* `Tecnativa `_: + + * Sergio Teruel + * Pedro M. Baeza diff --git a/sale_elaboration/readme/DESCRIPTION.rst b/sale_elaboration/readme/DESCRIPTION.rst index efb9a12c6cc..9b972169ca7 100644 --- a/sale_elaboration/readme/DESCRIPTION.rst +++ b/sale_elaboration/readme/DESCRIPTION.rst @@ -1,6 +1,7 @@ -This module extends the functionality of sale orders to allow to add an -elaboration in a sale order line and add an extra line with an elaboration -product linked to the elaboration. -An elaboration is a process that needs to be done over the product, usually on -picking/handling phase. It doesn't modify too much the product for needing an -specific product, but it adds a surcharge on the final price. +This module extends the functionality of sales orders to allow to set an +elaboration on lines that will add an extra order line with an elaboration +product linked to it when the delivery order is validated. + +An **elaboration** is a process that needs to be done over the product, usually +on picking/handling phase. It doesn't modify too much the product for needing +an specific product, but it adds a surcharge on the final price. diff --git a/sale_elaboration/readme/USAGE.rst b/sale_elaboration/readme/USAGE.rst index a7318257f0b..1dc2e2ccb27 100644 --- a/sale_elaboration/readme/USAGE.rst +++ b/sale_elaboration/readme/USAGE.rst @@ -1,5 +1,8 @@ -#. Go to *Sale > Quotations > Create*. - Create a sales order and select an elaboration in the line. -#. Go to the picking created by this sale order and validate it. -#. Go to *Sales > Quotation*. A new line is created with the product linked to +#. Go to *Sale > Quotations*. +#. Create a sales order. +#. Add a new line. +#. Select an elaboration in the line. +#. Confirm the sales order. +#. Go to the picking created by this sales order and validate it. +#. Go back to the sales order. A new line is created with the product linked to the elaboration. diff --git a/sale_elaboration/views/sale_elaboration_report_views.xml b/sale_elaboration/views/sale_elaboration_report_views.xml index a4c13a52eb8..80fd8271b54 100755 --- a/sale_elaboration/views/sale_elaboration_report_views.xml +++ b/sale_elaboration/views/sale_elaboration_report_views.xml @@ -1,5 +1,6 @@ @@ -33,8 +34,9 @@ /> - + diff --git a/sale_elaboration/views/sale_order_views.xml b/sale_elaboration/views/sale_order_views.xml index d8a97f8756a..17c26739981 100755 --- a/sale_elaboration/views/sale_order_views.xml +++ b/sale_elaboration/views/sale_order_views.xml @@ -1,5 +1,6 @@ @@ -14,7 +15,7 @@ - + From 5e973604be8d06a7abec72cd6370bd7da905e092 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Tue, 26 Mar 2019 13:46:31 +0100 Subject: [PATCH 07/76] [11.0][ADD] sale_elaboration: Add is_elaboration in product template --- sale_elaboration/__manifest__.py | 1 + sale_elaboration/i18n/es.po | 52 ++++-- sale_elaboration/i18n/sale_elaboration.pot | 175 ++++++++++++++++++ sale_elaboration/models/__init__.py | 1 + sale_elaboration/models/product.py | 9 + .../models/product_elaboration.py | 2 +- sale_elaboration/views/product_views.xml | 16 ++ .../views/sale_elaboration_views.xml | 4 +- 8 files changed, 240 insertions(+), 20 deletions(-) create mode 100644 sale_elaboration/i18n/sale_elaboration.pot create mode 100644 sale_elaboration/models/product.py create mode 100755 sale_elaboration/views/product_views.xml diff --git a/sale_elaboration/__manifest__.py b/sale_elaboration/__manifest__.py index 80b07d15dc9..2c4d9baa314 100644 --- a/sale_elaboration/__manifest__.py +++ b/sale_elaboration/__manifest__.py @@ -17,6 +17,7 @@ ], 'data': [ 'security/ir.model.access.csv', + 'views/product_views.xml', 'views/sale_elaboration_views.xml', 'views/sale_order_views.xml', 'views/sale_elaboration_report_views.xml', diff --git a/sale_elaboration/i18n/es.po b/sale_elaboration/i18n/es.po index 9fc118a9adf..ec4856bb7e3 100644 --- a/sale_elaboration/i18n/es.po +++ b/sale_elaboration/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-18 11:57+0000\n" -"PO-Revision-Date: 2018-10-18 13:58+0200\n" +"POT-Creation-Date: 2019-03-26 09:25+0000\n" +"PO-Revision-Date: 2019-03-26 10:26+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: es\n" @@ -17,6 +17,18 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.0.6\n" +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.report_delivery_document +msgid "Elab." +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.report_delivery_document +#, fuzzy +#| msgid "Elaborations" +msgid "Elaboration" +msgstr "Elaboraciones" + #. module: sale_elaboration #: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter msgid "After Date" @@ -27,6 +39,11 @@ msgstr "" msgid "Code must be unique!" msgstr "El código debe ser único." +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Confirmation Date" +msgstr "Fecha de confirmación" + #. module: sale_elaboration #: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_uid msgid "Created by" @@ -37,6 +54,11 @@ msgstr "Creado por" msgid "Created on" msgstr "Creado el" +#. module: sale_elaboration +#: model:ir.model.fields,help:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Date on which the sales order is confirmed." +msgstr "" + #. module: sale_elaboration #: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_display_name msgid "Display Name" @@ -77,6 +99,12 @@ msgstr "ID (identificación)" msgid "Is Elaboration" msgstr "Es elaboración" +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_product_is_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_template_is_elaboration +msgid "Is elaboration" +msgstr "Es elaboración" + #. module: sale_elaboration #: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration___last_update msgid "Last Modified on" @@ -102,16 +130,16 @@ msgstr "Nombre" msgid "Name must be unique!" msgstr "¡El nombre debe ser único!" -#. module: sale_elaboration -#: model:ir.model,name:sale_elaboration.model_stock_move_line -msgid "Packing Operation" -msgstr "" - #. module: sale_elaboration #: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_product_id msgid "Product" msgstr "Producto" +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + #. module: sale_elaboration #: model:ir.model,name:sale_elaboration.model_sale_order msgid "Quotation" @@ -139,21 +167,11 @@ msgstr "Líneas de pedido" msgid "Short Code" msgstr "Nombre corto" -#. module: sale_elaboration -#: model:ir.model,name:sale_elaboration.model_stock_move -msgid "Stock Move" -msgstr "" - #. module: sale_elaboration #: model:ir.model,name:sale_elaboration.model_stock_picking msgid "Transfer" msgstr "Transferir" -#. module: sale_elaboration -#: model:ir.model,name:sale_elaboration.model_elaboration -msgid "elaboration" -msgstr "Elaboración" - #. module: sale_elaboration #: model:ir.model,name:sale_elaboration.model_product_elaboration msgid "product.elaboration" diff --git a/sale_elaboration/i18n/sale_elaboration.pot b/sale_elaboration/i18n/sale_elaboration.pot new file mode 100644 index 00000000000..3235dec4941 --- /dev/null +++ b/sale_elaboration/i18n/sale_elaboration.pot @@ -0,0 +1,175 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-03-26 09:25+0000\n" +"PO-Revision-Date: 2019-03-26 09:25+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.report_delivery_document +msgid "Elab." +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.report_delivery_document +msgid "Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "After Date" +msgstr "" + +#. module: sale_elaboration +#: sql_constraint:product.elaboration:0 +msgid "Code must be unique!" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Confirmation Date" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_uid +msgid "Created by" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_date +msgid "Created on" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,help:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Date on which the sales order is confirmed." +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_display_name +msgid "Display Name" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_elaboration_id +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_search +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_elaboration_note +msgid "Elaboration Note" +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_form +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_tree +#: model:ir.ui.view,arch_db:sale_elaboration.report_elaboration_view_tree +msgid "Elaborations" +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_search +msgid "Elaborations Search" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_id +msgid "ID" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_is_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "Is Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_product_is_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_template_is_elaboration +msgid "Is elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration___last_update +msgid "Last Modified on" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_write_date +msgid "Last Updated on" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_name +msgid "Name" +msgstr "" + +#. module: sale_elaboration +#: sql_constraint:product.elaboration:0 +msgid "Name must be unique!" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_product_id +msgid "Product" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_product_template +msgid "Product Template" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_sale_order +msgid "Quotation" +msgstr "" + +#. module: sale_elaboration +#: model:ir.actions.act_window,name:sale_elaboration.sale_elaboration_action_form +#: model:ir.ui.menu,name:sale_elaboration.menu_sale_elaboration +msgid "Sale Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.actions.act_window,name:sale_elaboration.sale_elaboration_report_action +#: model:ir.ui.menu,name:sale_elaboration.menu_sale_elaboration_report +msgid "Sale Elaboration Report" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_code +msgid "Short Code" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_product_elaboration +msgid "product.elaboration" +msgstr "" + diff --git a/sale_elaboration/models/__init__.py b/sale_elaboration/models/__init__.py index 08e036c192d..36efa7be941 100644 --- a/sale_elaboration/models/__init__.py +++ b/sale_elaboration/models/__init__.py @@ -1,4 +1,5 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import product from . import product_elaboration from . import sale_order from . import stock_picking diff --git a/sale_elaboration/models/product.py b/sale_elaboration/models/product.py new file mode 100644 index 00000000000..14bf645b78e --- /dev/null +++ b/sale_elaboration/models/product.py @@ -0,0 +1,9 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_elaboration = fields.Boolean(string='Is elaboration') diff --git a/sale_elaboration/models/product_elaboration.py b/sale_elaboration/models/product_elaboration.py index ec8a2e4fdd9..f176ccdeaa9 100644 --- a/sale_elaboration/models/product_elaboration.py +++ b/sale_elaboration/models/product_elaboration.py @@ -18,7 +18,7 @@ class Elaboration(models.Model): comodel_name='product.product', string='Product', ondelete='restrict', - domain=[('type', '=', 'service')], + domain=[('type', '=', 'service'), ('is_elaboration', '=', True)], required=True, ) diff --git a/sale_elaboration/views/product_views.xml b/sale_elaboration/views/product_views.xml new file mode 100755 index 00000000000..2143f2d0cdc --- /dev/null +++ b/sale_elaboration/views/product_views.xml @@ -0,0 +1,16 @@ + + + + + + product.template + + + + + + + + + diff --git a/sale_elaboration/views/sale_elaboration_views.xml b/sale_elaboration/views/sale_elaboration_views.xml index 6ede232f302..bd2414322bc 100755 --- a/sale_elaboration/views/sale_elaboration_views.xml +++ b/sale_elaboration/views/sale_elaboration_views.xml @@ -12,7 +12,7 @@ - + @@ -26,7 +26,7 @@ - + From e6365e58e351ae21033d39df7288c57b457d5e4a Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 27 Mar 2019 20:47:06 +0100 Subject: [PATCH 08/76] [IMP] sale_elaboration: Ensure test correctness + hide is_elaboration if not service --- sale_elaboration/README.rst | 103 ++++ sale_elaboration/i18n/sale_elaboration.pot | 12 +- .../static/description/index.html | 452 ++++++++++++++++++ .../tests/test_sale_elaboration.py | 9 + sale_elaboration/views/product_views.xml | 2 +- 5 files changed, 570 insertions(+), 8 deletions(-) create mode 100644 sale_elaboration/README.rst create mode 100644 sale_elaboration/static/description/index.html diff --git a/sale_elaboration/README.rst b/sale_elaboration/README.rst new file mode 100644 index 00000000000..d763818ea6b --- /dev/null +++ b/sale_elaboration/README.rst @@ -0,0 +1,103 @@ +================ +Sale Elaboration +================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/11.0/sale_elaboration + :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-11-0/sale-workflow-11-0-sale_elaboration + :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/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of sales orders to allow to set an +elaboration on lines that will add an extra order line with an elaboration +product linked to it when the delivery order is validated. + +An **elaboration** is a process that needs to be done over the product, usually +on picking/handling phase. It doesn't modify too much the product for needing +an specific product, but it adds a surcharge on the final price. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module you need to: + +#. Go to *Sale > Configuration > Products > Elaboration Sale*. +#. Create a new record. +#. Set a product linked to the elaboration. + +Usage +===== + +#. Go to *Sale > Quotations*. +#. Create a sales order. +#. Add a new line. +#. Select an elaboration in the line. +#. Confirm the sales order. +#. Go to the picking created by this sales order and validate it. +#. Go back to the sales order. A new line is created with the product linked to + the elaboration. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Sergio Teruel + * Pedro M. Baeza + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_elaboration/i18n/sale_elaboration.pot b/sale_elaboration/i18n/sale_elaboration.pot index 3235dec4941..81af8291be0 100644 --- a/sale_elaboration/i18n/sale_elaboration.pot +++ b/sale_elaboration/i18n/sale_elaboration.pot @@ -6,8 +6,6 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-03-26 09:25+0000\n" -"PO-Revision-Date: 2019-03-26 09:25+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -35,11 +33,6 @@ msgstr "" msgid "Code must be unique!" msgstr "" -#. module: sale_elaboration -#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date -msgid "Confirmation Date" -msgstr "" - #. module: sale_elaboration #: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_uid msgid "Created by" @@ -50,6 +43,11 @@ msgstr "" msgid "Created on" msgstr "" +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Date" +msgstr "" + #. module: sale_elaboration #: model:ir.model.fields,help:sale_elaboration.field_sale_order_line_confirmation_date msgid "Date on which the sales order is confirmed." diff --git a/sale_elaboration/static/description/index.html b/sale_elaboration/static/description/index.html new file mode 100644 index 00000000000..7c816977d9d --- /dev/null +++ b/sale_elaboration/static/description/index.html @@ -0,0 +1,452 @@ + + + + + + +Sale Elaboration + + + +
+

Sale Elaboration

+ + +

Beta License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runbot

+

This module extends the functionality of sales orders to allow to set an +elaboration on lines that will add an extra order line with an elaboration +product linked to it when the delivery order is validated.

+

An elaboration is a process that needs to be done over the product, usually +on picking/handling phase. It doesn’t modify too much the product for needing +an specific product, but it adds a surcharge on the final price.

+

Table of contents

+ +
+

Configuration

+

To configure this module you need to:

+
    +
  1. Go to Sale > Configuration > Products > Elaboration Sale.
  2. +
  3. Create a new record.
  4. +
  5. Set a product linked to the elaboration.
  6. +
+
+
+

Usage

+
    +
  1. Go to Sale > Quotations.
  2. +
  3. Create a sales order.
  4. +
  5. Add a new line.
  6. +
  7. Select an elaboration in the line.
  8. +
  9. Confirm the sales order.
  10. +
  11. Go to the picking created by this sales order and validate it.
  12. +
  13. Go back to the sales order. A new line is created with the product linked to +the elaboration.
  14. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Sergio Teruel
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/sale-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/sale_elaboration/tests/test_sale_elaboration.py b/sale_elaboration/tests/test_sale_elaboration.py index 7c1192e3322..102ef19557a 100644 --- a/sale_elaboration/tests/test_sale_elaboration.py +++ b/sale_elaboration/tests/test_sale_elaboration.py @@ -27,8 +27,17 @@ def setUpClass(cls): 'list_price': 25.0, 'invoice_policy': 'order', }) + cls.pricelist = cls.env['product.pricelist'].create({ + 'name': 'Test pricelist', + 'item_ids': [(0, 0, { + 'applied_on': '3_global', + 'compute_price': 'formula', + 'base': 'list_price', + })] + }) cls.partner = cls.env['res.partner'].create({ 'name': 'test - partner', + 'property_product_pricelist': cls.pricelist.id, }) cls.elaboration_a = cls.Elaboration.create({ 'code': 'AA', diff --git a/sale_elaboration/views/product_views.xml b/sale_elaboration/views/product_views.xml index 2143f2d0cdc..89b08e6fc18 100755 --- a/sale_elaboration/views/product_views.xml +++ b/sale_elaboration/views/product_views.xml @@ -8,7 +8,7 @@ - + From be14669c991aa0c5ae6e178bf8a91b0829c41319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Scaraf=C3=ADa?= Date: Thu, 11 Apr 2019 11:06:08 -0300 Subject: [PATCH 09/76] [11.0][FIX] sale_elaboration should't be auto installed --- sale_elaboration/__manifest__.py | 2 +- sale_elaboration/i18n/es.po | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sale_elaboration/__manifest__.py b/sale_elaboration/__manifest__.py index 2c4d9baa314..7b0de2eb565 100644 --- a/sale_elaboration/__manifest__.py +++ b/sale_elaboration/__manifest__.py @@ -11,7 +11,7 @@ 'license': 'AGPL-3', 'application': False, 'installable': True, - 'auto_install': True, + 'auto_install': False, 'depends': [ 'sale_stock', ], diff --git a/sale_elaboration/i18n/es.po b/sale_elaboration/i18n/es.po index ec4856bb7e3..f4bfe0c2e7a 100644 --- a/sale_elaboration/i18n/es.po +++ b/sale_elaboration/i18n/es.po @@ -39,11 +39,6 @@ msgstr "" msgid "Code must be unique!" msgstr "El código debe ser único." -#. module: sale_elaboration -#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date -msgid "Confirmation Date" -msgstr "Fecha de confirmación" - #. module: sale_elaboration #: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_uid msgid "Created by" @@ -54,6 +49,11 @@ msgstr "Creado por" msgid "Created on" msgstr "Creado el" +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Date" +msgstr "" + #. module: sale_elaboration #: model:ir.model.fields,help:sale_elaboration.field_sale_order_line_confirmation_date msgid "Date on which the sales order is confirmed." @@ -176,3 +176,6 @@ msgstr "Transferir" #: model:ir.model,name:sale_elaboration.model_product_elaboration msgid "product.elaboration" msgstr "Elaboración" + +#~ msgid "Confirmation Date" +#~ msgstr "Fecha de confirmación" From 3c1edbd1cc2c6c41776aca1d12ff7d1a28c2a6d6 Mon Sep 17 00:00:00 2001 From: Maria Sparenberg Date: Mon, 15 Jul 2019 11:27:30 +0000 Subject: [PATCH 10/76] Added translation using Weblate (German) --- sale_elaboration/i18n/de.po | 175 ++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 sale_elaboration/i18n/de.po diff --git a/sale_elaboration/i18n/de.po b/sale_elaboration/i18n/de.po new file mode 100644 index 00000000000..41e2a768639 --- /dev/null +++ b/sale_elaboration/i18n/de.po @@ -0,0 +1,175 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_elaboration +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-07-17 11:43+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.7.1\n" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.report_delivery_document +msgid "Elab." +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.report_delivery_document +msgid "Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "After Date" +msgstr "" + +#. module: sale_elaboration +#: sql_constraint:product.elaboration:0 +msgid "Code must be unique!" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_uid +msgid "Created by" +msgstr "Erstellt von" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_create_date +msgid "Created on" +msgstr "Erstellt am" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Date" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,help:sale_elaboration.field_sale_order_line_confirmation_date +msgid "Date on which the sales order is confirmed." +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_display_name +msgid "Display Name" +msgstr "Anzeigename" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_elaboration_id +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_search +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_elaboration_note +msgid "Elaboration Note" +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_form +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_tree +#: model:ir.ui.view,arch_db:sale_elaboration.report_elaboration_view_tree +msgid "Elaborations" +msgstr "" + +#. module: sale_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.elaboration_view_search +msgid "Elaborations Search" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_id +msgid "ID" +msgstr "ID" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_sale_order_line_is_elaboration +#: model:ir.ui.view,arch_db:sale_elaboration.view_sales_order_line_filter +msgid "Is Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_product_is_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_template_is_elaboration +msgid "Is elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration___last_update +msgid "Last Modified on" +msgstr "Zuletzt geändert am" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_write_uid +msgid "Last Updated by" +msgstr "Zuletzt aktualisiert von" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_write_date +msgid "Last Updated on" +msgstr "Zuletzt aktualisiert am" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_name +msgid "Name" +msgstr "Bezeichnung" + +#. module: sale_elaboration +#: sql_constraint:product.elaboration:0 +msgid "Name must be unique!" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_product_id +msgid "Product" +msgstr "Produkt" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_product_template +msgid "Product Template" +msgstr "Produktvorlage" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_sale_order +msgid "Quotation" +msgstr "Angebot" + +#. module: sale_elaboration +#: model:ir.actions.act_window,name:sale_elaboration.sale_elaboration_action_form +#: model:ir.ui.menu,name:sale_elaboration.menu_sale_elaboration +msgid "Sale Elaboration" +msgstr "" + +#. module: sale_elaboration +#: model:ir.actions.act_window,name:sale_elaboration.sale_elaboration_report_action +#: model:ir.ui.menu,name:sale_elaboration.menu_sale_elaboration_report +msgid "Sale Elaboration Report" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model.fields,field_description:sale_elaboration.field_product_elaboration_code +msgid "Short Code" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: sale_elaboration +#: model:ir.model,name:sale_elaboration.model_product_elaboration +msgid "product.elaboration" +msgstr "" From 2f956345773fd9033998c573c700fa08f710c8f9 Mon Sep 17 00:00:00 2001 From: Sergio Teruel Date: Fri, 19 Jul 2019 10:07:31 +0200 Subject: [PATCH 11/76] [IMP] sale_elaboration: Reset "is_elaboration" in order line when user changes product --- sale_elaboration/models/sale_order.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sale_elaboration/models/sale_order.py b/sale_elaboration/models/sale_order.py index 78fa621cf9d..7471a4a649a 100644 --- a/sale_elaboration/models/sale_order.py +++ b/sale_elaboration/models/sale_order.py @@ -70,3 +70,9 @@ def _prepare_invoice_line(self, qty): if self.is_elaboration: vals['name'] = '{} - {}'.format(self.order_id.name, self.name) return vals + + @api.onchange('product_id') + def product_id_change(self): + result = super().product_id_change() + self.is_elaboration = self.product_id.is_elaboration + return result From 0f5d8dbdbb45b34a29c542cfef13a8172d9d4289 Mon Sep 17 00:00:00 2001 From: Carlos Dauden Date: Mon, 22 Jul 2019 17:30:09 +0200 Subject: [PATCH 12/76] [IMP] sale_elaboration: Set is_elaboration in product tests --- sale_elaboration/__manifest__.py | 2 +- sale_elaboration/static/description/index.html | 2 +- sale_elaboration/tests/test_sale_elaboration.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sale_elaboration/__manifest__.py b/sale_elaboration/__manifest__.py index 7b0de2eb565..20b8cc3cd63 100644 --- a/sale_elaboration/__manifest__.py +++ b/sale_elaboration/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Sale Elaboration', 'summary': 'Set an elaboration for any sale line', - 'version': '11.0.1.0.0', + 'version': '11.0.1.0.1', 'development_status': 'Beta', 'category': 'Sale', 'website': 'https://github.com/OCA/sale-workflow', diff --git a/sale_elaboration/static/description/index.html b/sale_elaboration/static/description/index.html index 7c816977d9d..16977c0c9dc 100644 --- a/sale_elaboration/static/description/index.html +++ b/sale_elaboration/static/description/index.html @@ -3,7 +3,7 @@ - + Sale Elaboration