Browse Source

Agregar en receta precio de costo

sebas 2 years ago
parent
commit
0c6e994e65

BIN
__init__.pyc


BIN
models/__init__.pyc


+ 39 - 1
models/pack.py

@@ -33,11 +33,21 @@ class product_pack(models.Model):
         'Discount (%)',
         digits=dp.get_precision('Discount'),
         )
+    pricecosto = fields.Float(
+        'Precio Costo',
+        required=True,
+        default=0.0,
+        )
     price = fields.Float(
-        'Precio',
+        'Precio ',
         required=True,
         default=0.0,
         )
+    subtotalcosto = fields.Float(
+        'Subtotal Costo',
+        required=True,
+        compute="_product_price_subtotalcosto"
+        )
     subtotal = fields.Float(
         'Subtotal',
         required=True,
@@ -54,6 +64,16 @@ class product_pack(models.Model):
 
         self.subtotal = self.price * self.quantity
 
+    @api.one
+    @api.depends('product_id')
+    def _product_price_subtotalcosto(self):
+        if(self.pricecosto > 0):
+            self.subtotalcosto = self.pricecosto * self.quantity
+        else:
+            self.pricecosto = self.product_id.standard_price
+
+        self.subtotalcosto = self.pricecosto * self.quantity
+
     @api.onchange('price')
     def _product_change_price_subtotal(self):
         if(self.price > 0):
@@ -63,6 +83,15 @@ class product_pack(models.Model):
 
         self.subtotal = self.price * self.quantity
 
+    @api.onchange('pricecosto')
+    def _product_change_price_subtotalcosto(self):
+        if(self.pricecosto > 0):
+            self.subtotalcosto = self.pricecosto * self.quantity
+        else:
+            self.pricecosto = self.product_id.standard_price
+
+        self.subtotalcosto = self.pricecosto * self.quantity
+
     @api.onchange('quantity')
     def _product_change_quantity_subtotal(self):
         if(self.price > 0):
@@ -72,6 +101,15 @@ class product_pack(models.Model):
 
         self.subtotal = self.price * self.quantity
 
+    @api.onchange('quantity')
+    def _product_change_quantity_subtotalcosto(self):
+        if(self.pricecosto > 0):
+            self.subtotalcosto = self.pricecosto * self.quantity
+        else:
+            self.pricecosto = self.product_id.standard_price
+
+        self.subtotalcosto = self.pricecosto * self.quantity
+
     @api.multi
     def get_sale_order_line_vals(self, line, order):
         self.ensure_one()

BIN
models/pack.pyc


BIN
models/product.pyc


BIN
models/sale_order.pyc


BIN
models/sale_order_line.pyc


BIN
models/sale_order_line_pack_line.pyc


+ 4 - 0
views/pack_view.xml

@@ -47,8 +47,10 @@
 				<group>
 					<field name="product_id"/>
 					<field name="quantity"/>
+					<field name="pricecosto" string="Precio Costo"/>
 					<field name="price" string="Precio"/>
 					<field name="subtotal"/>
+					<field name="subtotalcosto"/>
 					<!-- <field name="discount" groups="sale.group_discount_per_so_line" invisible="context.get('pack_price_type') == 'fixed_price'"/> -->
 				</group>
 			</form>
@@ -63,7 +65,9 @@
 			<tree string="Pack Product Lines" editable="bottom">
 				<field name="product_id"/>
 				<field name="quantity"/>
+				<field name="pricecosto" string="Precio Costo"/>
 				<field name="price" string="Precio"/>
+				<field name="subtotalcosto" sum="totalcosto"/>
 				<field name="subtotal" sum="total"/>
 				<!-- <field name="discount" groups="sale.group_discount_per_so_line" invisible="context.get('pack_price_type') == 'fixed_price'"/> -->
 			</tree>