Kaynağa Gözat

[ADD] Modificacion de las vistas

Rodney Elpidio Enciso Arias 6 yıl önce
ebeveyn
işleme
a9b116ad2d

+ 0 - 0
README.rst


+ 0 - 0
__init__.py


BIN
__init__.pyc


+ 4 - 3
__openerp__.py

@@ -4,10 +4,11 @@
 
 {
     'name': 'Products Pricelist Prices',
-    'version': '8.0.1.1.2',
-    'author': 'ICTSTUDIO, André Schenkels',
+    'version': '8.0.1.1.5',
+    'author': 'ICTSTUDIO, André Schenkels - Eiru',
+    'website': 'http://www.ictstudio.eu',
+    'license': 'AGPL-3',
     'category': 'Sales Management',
-    'website': 'https://www.odoo.com',
     'depends': ['product'],
     'demo': [],
     'summary': "Show Price for Available Pricelists",

+ 1 - 0
models/__init__.py

@@ -3,5 +3,6 @@
 # License: AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
 
 from . import product_pricelist
+from . import product_pricelist_item
 from . import product_template
 

BIN
models/__init__.pyc


+ 1 - 0
models/product_pricelist.py

@@ -165,6 +165,7 @@ class product_pricelist(models.Model):
         for item in items:
             _logger.debug("Remove Item: %s", item)
             item.unlink()
+
         return True
 
 

BIN
models/product_pricelist.pyc


+ 41 - 0
models/product_pricelist_item.py

@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# Copyright© 2016 ICTSTUDIO <http://www.ictstudio.eu>
+# License: AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
+
+import logging
+
+from openerp import models, fields, api, _
+
+_logger = logging.getLogger(__name__)
+
+class ProductPricelistItem(models.Model):
+    _inherit = 'product.pricelist.item'
+
+    @api.multi
+    def change_product(self):
+
+        for rec in self:
+            if rec.product_tmpl_id:
+                rec.product_tmpl_id.write({'write_uid': self._uid})
+            if rec.product_id:
+                rec.product_id.write({'write_uid': self._uid})
+
+        return True
+
+    @api.multi
+    def unlink(self):
+        self.change_product()
+        return super(ProductPricelistItem, self).unlink()
+
+    @api.multi
+    def write(self, vals):
+        ret = super(ProductPricelistItem, self).write(vals)
+        self.change_product()
+        return ret
+
+    @api.model
+    def create(self, vals):
+        items = super(ProductPricelistItem, self).create(vals)
+        if items:
+            items.change_product()
+        return items

BIN
models/product_pricelist_item.pyc


+ 23 - 1
models/product_template.py

@@ -15,7 +15,8 @@ class ProductTemplate(models.Model):
     def _get_pricelists(self):
         self.pricelists = self.env['product.pricelist'].search(
                 [
-                    ('show_on_products', '=', True)
+                    ('show_on_products', '=', True),
+                    ('type', '=', 'sale')
                 ]
         )
 
@@ -24,6 +25,21 @@ class ProductTemplate(models.Model):
             if pricelist.product_price:
                 _logger.debug("Updating Price: %s", pricelist.product_price)
                 pricelist.price_set(self, pricelist.product_price)
+
+    @api.one
+    def _get_purchase_pricelists(self):
+        self.purchase_pricelists = self.env['product.pricelist'].search(
+                [
+                    ('show_on_products', '=', True),
+                    ('type', '=', 'purchase')
+                ]
+        )
+
+    def _set_purchase_pricelists(self):
+        for pricelist in self.purchase_pricelists:
+            if pricelist.product_price:
+                _logger.debug("Updating Price: %s", pricelist.product_price)
+                pricelist.price_set(self, pricelist.product_price)
     
     pricelists = fields.One2many(
             comodel_name="product.pricelist",
@@ -32,3 +48,9 @@ class ProductTemplate(models.Model):
             inverse="_set_pricelists"
     )
 
+    purchase_pricelists = fields.One2many(
+            comodel_name="product.pricelist",
+            string="Purchase Pricelists",
+            compute="_get_purchase_pricelists",
+            inverse="_set_purchase_pricelists"
+    )

BIN
models/product_template.pyc


+ 0 - 0
static/description/icon.png


+ 0 - 0
views/product_pricelist.xml


+ 28 - 12
views/product_product.xml

@@ -7,18 +7,34 @@
             <field name="model">product.product</field>
             <field name="inherit_id" ref="product.product_normal_form_view"/>
             <field name="arch" type="xml">   
-                <field name="active" position="after">
-                    <field name="pricelists" nolabel="1" colspan="2" context="{'product_id': active_id}">
-                        <tree string="Precio" editable="bottom" create="false" delete="false" colors="red:product_price_manual">
-                            <field name="name" readonly="1"/>
-                            <field name="product_price_manual" invisible="1"/>
-                            <field name="product_price" string="Precio"/>
-                            <!-- <button  type="object" icon="STOCK_CLOSE"
-                                     name="remove_price_manual"
-                            /> -->
-                        </tree>
-                    </field>
-                </field> 
+                <field name="description" position="before">
+                    <group>
+                        <group string="Precios de Venta">
+                            <field name="pricelists" nolabel="1" colspan="2" context="{'product_id': active_id}">
+                                <tree string="Sale Prices" editable="bottom" create="false" delete="false" colors="red:product_price_manual">
+                                    <field name="name" readonly="1"/>
+                                    <field name="product_price_manual" invisible="1"/>
+                                    <field name="product_price" string="Precio"/>
+                                    <button  type="object" icon="STOCK_CLOSE"
+                                             name="remove_price_manual"
+                                    />
+                                </tree>
+                            </field>
+                        </group>
+                        <group string="Precios de Compra">
+                            <field name="purchase_pricelists" nolabel="1" colspan="2" context="{'product_id': active_id}">
+                                <tree string="Purchase Prices" editable="bottom" create="false" delete="false" colors="red:product_price_manual">
+                                    <field name="name" readonly="1"/>
+                                    <field name="product_price_manual" invisible="1"/>
+                                    <field name="product_price" string="Precio"/>
+                                    <button  type="object" icon="STOCK_CLOSE"
+                                             name="remove_price_manual"
+                                    />
+                                </tree>
+                            </field>
+                        </group>
+                    </group>
+                </field>
             </field>
         </record>
 

+ 27 - 11
views/product_template.xml

@@ -7,17 +7,33 @@
             <field name="model">product.template</field>
             <field name="inherit_id" ref="product.product_template_only_form_view"/>
             <field name="arch" type="xml">
-                <field name="active" position="after">
-                    <field name="pricelists" nolabel="1" colspan="2" context="{'product_template_id': active_id}">
-                        <tree string="Precio" editable="bottom" create="false" delete="false" colors="red:product_price_manual">
-                            <field name="name" readonly="1"/>
-                            <field name="product_price_manual" invisible="1"/>
-                            <field name="product_price" string="Precio"/>
-                            <!-- <button  type="object" icon="STOCK_CLOSE"
-                                     name="remove_price_manual"
-                            /> -->
-                        </tree>
-                    </field>
+                <field name="description" position="before">
+                    <group>
+                        <group string="Precios de Venta">
+                            <field name="pricelists" nolabel="1" colspan="2" context="{'product_template_id': active_id}">
+                                <tree string="Sale Prices" editable="bottom" create="false" delete="false" colors="red:product_price_manual">
+                                    <field name="name" readonly="1"/>
+                                    <field name="product_price_manual" invisible="1"/>
+                                    <field name="product_price" string="Precio"/>
+                                    <button  type="object" icon="STOCK_CLOSE"
+                                             name="remove_price_manual"
+                                    />
+                                </tree>
+                            </field>
+                        </group>
+                        <group string="Precios de Compra">
+                            <field name="purchase_pricelists" nolabel="1" colspan="2" context="{'product_template_id': active_id}">
+                                <tree string="Purchase Prices" editable="bottom" create="false" delete="false" colors="red:product_price_manual">
+                                    <field name="name" readonly="1"/>
+                                    <field name="product_price_manual" invisible="1"/>
+                                    <field name="product_price" string="Precio"/>
+                                    <button  type="object" icon="STOCK_CLOSE"
+                                             name="remove_price_manual"
+                                    />
+                                </tree>
+                            </field>
+                        </group>    
+                    </group>
                 </field>
             </field>
         </record>