Prechádzať zdrojové kódy

[ADD] Precios de costo y Subtotal en el formulario del producto

Rodney Elpidio Enciso Arias 7 rokov pred
rodič
commit
527344c498
5 zmenil súbory, kde vykonal 37 pridanie a 12 odobranie
  1. 20 0
      models/pack.py
  2. BIN
      models/pack.pyc
  3. 7 6
      models/product.py
  4. BIN
      models/product.pyc
  5. 10 6
      views/pack_view.xml

+ 20 - 0
models/pack.py

@@ -28,10 +28,30 @@ class product_pack(models.Model):
         ondelete='cascade',
         required=True,
         )
+
     discount = fields.Float(
         'Discount (%)',
         digits=dp.get_precision('Discount'),
         )
+    price = fields.Float(
+        'Precio',
+        required=True,
+        default=0.0,
+        )
+    subtotal = fields.Float(
+        'Subtotal',
+        required=True,
+        default=0.0,
+        )
+
+    @api.onchange('product_id')
+    def get_price(self):
+        self.price = self.product_id.standard_price
+        self.subtotal = self.price * self.quantity
+
+    @api.onchange('quantity')
+    def get_subtotal(self):
+        self.subtotal = self.price * self.quantity
 
     @api.multi
     def get_sale_order_line_vals(self, line, order):

BIN
models/pack.pyc


+ 7 - 6
models/product.py

@@ -105,11 +105,11 @@ class product_template(models.Model):
 
     # TODO rename a pack_type
     pack_price_type = fields.Selection([
-        ('components_price', 'Detailed - Components Prices'),
-        ('totalice_price', 'Detailed - Totaliced Price'),
-        ('fixed_price', 'Detailed - Fixed Price'),
-        ('none_detailed_assited_price', 'None Detailed - Assisted Price'),
-        ('none_detailed_totaliced_price', 'None Detailed - Totaliced Price'),
+        ('components_price', 'Detallado - Precios de los componentes'),
+        ('totalice_price', 'Detallado - Precio total'),
+        ('fixed_price', 'Detallado - Precio fijo'),
+        ('none_detailed_assited_price', 'No detallado - Precio Asistido'),
+        ('none_detailed_totaliced_price', 'No detallado - Precio total'),
     ],
         'Pack Type',
         help="* Detailed - Components Prices: Detail lines with prices on "
@@ -119,7 +119,8 @@ class product_template(models.Model):
         "* Detailed - Fixed Price: Detail lines on sales order and use product"
         " pack price (ignore line prices).\n"
         "* None Detailed - Assisted Price: Do not detail lines on sales "
-        "order. Assist to get pack price using pack lines."
+        "order. Assist to get pack price using pack lines.",
+        default='fixed_price'
         )
     pack = fields.Boolean(
         'Pack?',

BIN
models/product.pyc


+ 10 - 6
views/pack_view.xml

@@ -9,11 +9,11 @@
 		<field name="inherit_id" ref="product.product_template_only_form_view" />
 		<field name="arch" type="xml">
 			<field name="type" position="after">
-				<field name="pack"/>
-				<field name="pack_price_type" attrs="{'invisible':[('pack', '=', False)], 'required':[('pack','=',True)]}" context="{'pack_price_type': pack_price_type}"/>
+				<field name="pack" string="¿Es un paquete?"/>
+				<field name="pack_price_type" attrs="{'invisible':[('pack', '=', False)], 'required':[('pack','=',True)]}" context="{'pack_price_type': pack_price_type}" string="Tipo de paquete"/>
 			</field>
 			<notebook position="inside">
-				<page string="Pack" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('pack', '=', False)]}">
+				<page string="Lista de productos" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('pack', '=', False)]}">
 					<field name="pack_line_ids"/>
 				</page>
 			</notebook>
@@ -26,11 +26,11 @@
 		<field name="inherit_id" ref="product.product_normal_form_view" />
 		<field name="arch" type="xml">
 			<field name="type" position="after">
-				<field name="pack"/>
-				<field name="pack_price_type" attrs="{'invisible':[('pack', '=', False)], 'required':[('pack','=',True)]}" context="{'pack_price_type': pack_price_type}"/>
+				<field name="pack" string="¿Es un paquete?"/>
+				<field name="pack_price_type" attrs="{'invisible':[('pack', '=', False)], 'required':[('pack','=',True)]}" context="{'pack_price_type': pack_price_type}" string="Tipo de paquete"/>
 			</field>
 			<notebook position="inside">
-				<page string="Pack" attrs="{'invisible':[('pack', '=', False)]}">
+				<page string="Lista de productos" attrs="{'invisible':[('pack', '=', False)]}">
 					<field name="pack_line_ids"/>
 				</page>
 			</notebook>
@@ -47,6 +47,8 @@
 				<group>
 					<field name="product_id"/>
 					<field name="quantity"/>
+					<field name="price" string="Precio de Costo"/>
+					<field name="subtotal"/>
 					<field name="discount" groups="sale.group_discount_per_so_line" invisible="context.get('pack_price_type') == 'fixed_price'"/>
 				</group>
 			</form>
@@ -61,6 +63,8 @@
 			<tree string="Pack Product Lines" editable="bottom">
 				<field name="product_id"/>
 				<field name="quantity"/>
+				<field name="price" string="Precio de Costo"/>
+				<field name="subtotal" sum="total"/>
 				<field name="discount" groups="sale.group_discount_per_so_line" invisible="context.get('pack_price_type') == 'fixed_price'"/>
 			</tree>
 		</field>