|
@@ -0,0 +1,48 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+#################################################################################
|
|
|
+# #
|
|
|
+# product_genre for OpenERP #
|
|
|
+# Author: Victor Obrist #
|
|
|
+# contact: victor@paraguayenlaweb.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 api, fields, models
|
|
|
+
|
|
|
+class MrpProduction(models.Model):
|
|
|
+ _inherit = 'mrp.production'
|
|
|
+
|
|
|
+ partner_id = fields.Many2one(
|
|
|
+ comodel_name='res.partner', string='Customer', store=True,
|
|
|
+ related='move_prod_id.procurement_id.sale_line_id.order_id.partner_id')
|
|
|
+ sale_order_id = fields.Many2one(
|
|
|
+ comodel_name='sale.order', string='Sale Order', store=True,
|
|
|
+ related='move_prod_id.procurement_id.sale_line_id.order_id')
|
|
|
+ sale_line_id = fields.Many2one(
|
|
|
+ comodel_name='sale.order.line', string='Sale Line', store=True,
|
|
|
+ related='move_prod_id.procurement_id.sale_line_id')
|
|
|
+
|
|
|
+
|
|
|
+class Sale(models.Model):
|
|
|
+ _inherit = 'sale.order'
|
|
|
+
|
|
|
+ production_ids = fields.One2many(comodel_name='mrp.production', inverse_name='sale_order_id', string='Production')
|
|
|
+
|
|
|
+ production_count = fields.Integer(compute="_get_production_count")
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def _get_production_count(self):
|
|
|
+ if self.production_ids:
|
|
|
+ self.production_count = len(self.production_ids)
|