Parcourir la source

[FIX] ajustes varios

Rodney Elpidio Enciso Arias il y a 6 ans
Parent
commit
258ed3458d
2 fichiers modifiés avec 23 ajouts et 10 suppressions
  1. 23 10
      models/pack.py
  2. BIN
      models/pack.pyc

+ 23 - 10
models/pack.py

@@ -44,19 +44,32 @@ class product_pack(models.Model):
         compute="_product_price_subtotal"
         )
 
-    # @api.onchange('product_id')
-    # def get_price(self):
-    #     self.price = self.product_id.lst_price
-    #     self.subtotal = self.price * self.quantity
-
-    # @api.onchange('quantity') 
-    # def get_subtotal(self):
-    #     self.subtotal = self.price * self.quantity
-
     @api.one
     @api.depends('product_id')
     def _product_price_subtotal(self):
-        self.price = self.product_id.lst_price
+        if(self.price > 0):
+            self.subtotal = self.price * self.quantity
+        else:
+            self.price = self.product_id.lst_price
+
+        self.subtotal = self.price * self.quantity
+
+    @api.onchange('price')
+    def _product_change_price_subtotal(self):
+        if(self.price > 0):
+            self.subtotal = self.price * self.quantity
+        else:
+            self.price = self.product_id.lst_price
+
+        self.subtotal = self.price * self.quantity
+
+    @api.onchange('quantity')
+    def _product_change_quantity_subtotal(self):
+        if(self.price > 0):
+            self.subtotal = self.price * self.quantity
+        else:
+            self.price = self.product_id.lst_price
+
         self.subtotal = self.price * self.quantity
 
     @api.multi

BIN
models/pack.pyc