diff --git a/__manifest__.py b/__manifest__.py index 6fc7670337774fc64ec146c5446cc2c4c6598956..f26a87b22f58b9bf97810a714afa7b63632ff5c1 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -28,7 +28,7 @@ 'company': "Eynes - Ingenieria del software", 'website': "https://www.eynes.com.ar", 'category': 'Custom', - 'depends': ['mrp', 'quality_control', 'delivery'], + 'depends': ['mrp', 'quality_control', 'delivery', 'mrp_production_service'], 'data': [ #~ 'security/ir.model.access.csv', 'views/quality_control_view.xml', diff --git a/i18n/es_AR.po b/i18n/es_AR.po index 5338c5dae50070993372d47d6f56f3f60906a4b2..fbcdd79ca4a5ae06bc3751e3f61954f73d88d3ae 100644 --- a/i18n/es_AR.po +++ b/i18n/es_AR.po @@ -49,6 +49,12 @@ msgstr "Manufacturing Order" msgid "Operation Type" msgstr "Tipo de operación" +#. module: emu_custom +#: model:ir.model.fields,field_description:emu_custom.field_product_product_subcontracting_service_proc_rule_id +#: model:ir.model.fields,field_description:emu_custom.field_product_template_subcontracting_service_proc_rule_id +msgid "Subcontracting Service Procurement Rule" +msgstr "Regla de subcontratación de servicio" + #. module: emu_custom #: model:ir.model,name:emu_custom.model_product_template msgid "Product Template" diff --git a/models/product.py b/models/product.py index b3a4f85ff06ade5d39319cd70a6805969c212c11..c240f470570f148f9f03aea95721fce4eee2b545 100644 --- a/models/product.py +++ b/models/product.py @@ -24,9 +24,13 @@ from odoo import api, fields, models, _ class ProductTemplate(models.Model): _inherit = 'product.template' - + picking_type_id = fields.Many2one('stock.picking.type', string='Operation Type') - + subcontracting_service_proc_rule_id = fields.Many2one( + comodel_name='procurement.rule', + string="Subcontracting Service Procurement Rule" + ) + class MrpProduction(models.Model): _inherit = 'mrp.production' diff --git a/models/purchase.py b/models/purchase.py index 272247c4313ee68b6935040ef7db03d89b1ff043..15a13c91b21a06929e2db7944ef07f07dac31fc6 100644 --- a/models/purchase.py +++ b/models/purchase.py @@ -42,6 +42,21 @@ class PurchaseOrder(models.Model): res = super(PurchaseOrder, self).create(values) return res + +class ProcurementGroup(models.Model): + _inherit = "procurement.group" + + @api.model + def _get_rule(self, product_id, location_id, values): + res = super()._get_rule(product_id, location_id, values) + if not res: + if self._is_subcontracted_service(product_id): + rule_id = product_id.product_tmpl_id.subcontracting_service_proc_rule_id + if rule_id: + return rule_id + return res + + class ProcurementRule(models.Model): _inherit = 'procurement.rule' diff --git a/views/product_view.xml b/views/product_view.xml index 6ff6d512a8261994814de6256d0681c818bd1093..f529f7491d47f5b3c31606266971adf4d06bb811 100644 --- a/views/product_view.xml +++ b/views/product_view.xml @@ -13,5 +13,16 @@ </field> </record> + <record id="product_template_emu_custom_view_form" model="ir.ui.view"> + <field name="name">product_template_emu_custom_view_form</field> + <field name="model">product.template</field> + <field name="inherit_id" ref="product.product_template_form_view"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='type']" position="after"> + <field name="subcontracting_service_proc_rule_id" attrs="{'invisible': [('type', '!=', 'service')]}"/> + </xpath> + </field> + </record> + </data> </odoo>