Kaynağa Gözat

[FIX] correciones para facturas de proveedor y de cliente

Rodney Enciso Arias 7 yıl önce
ebeveyn
işleme
72da76f6cd

+ 0 - 0
.scannerwork/.sonar_lock


+ 2 - 2
.scannerwork/report-task.txt

@@ -1,5 +1,5 @@
 projectKey=account:invoice:line:pricelist
 projectKey=account:invoice:line:pricelist
 serverUrl=http://181.40.66.126:9000
 serverUrl=http://181.40.66.126:9000
 dashboardUrl=http://181.40.66.126:9000/dashboard/index/account:invoice:line:pricelist
 dashboardUrl=http://181.40.66.126:9000/dashboard/index/account:invoice:line:pricelist
-ceTaskId=AV9VGl1CLmS3QZZeLmuE
-ceTaskUrl=http://181.40.66.126:9000/api/ce/task?id=AV9VGl1CLmS3QZZeLmuE
+ceTaskId=AV9YmeQ9LmS3QZZeLmuG
+ceTaskUrl=http://181.40.66.126:9000/api/ce/task?id=AV9YmeQ9LmS3QZZeLmuG

+ 0 - 0
README.rst


+ 0 - 0
__init__.py


+ 0 - 0
__init__.pyc


+ 0 - 0
__openerp__.py


+ 0 - 0
models/__init__.py


+ 0 - 0
models/__init__.pyc


+ 5 - 0
models/account_invoice.py

@@ -47,3 +47,8 @@ class AccountInvoice(models.Model):
                         'currency_id': partner.property_product_pricelist.currency_id.id
                         'currency_id': partner.property_product_pricelist.currency_id.id
                     })
                     })
         return res
         return res
+
+    @api.one
+    @api.onchange('pricelist_id')
+    def onchange_pricelist_id(self):
+        self.currency_id = self.pricelist_id.currency_id.id

BIN
models/account_invoice.pyc


+ 0 - 2
models/account_invoice_line.py

@@ -20,8 +20,6 @@ class AccountInvoiceLine(models.Model):
             company_id=company_id)
             company_id=company_id)
         if not res or not res['value']:
         if not res or not res['value']:
             return res
             return res
-        if type not in ['out_invoice', 'out_refund']:
-            return res
         if not partner_id or not product:
         if not partner_id or not product:
             return res
             return res
 
 

BIN
models/account_invoice_line.pyc


+ 0 - 0
sonar-project.properties


+ 0 - 5
tests/__init__.py

@@ -1,5 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2016 Onestein (<http://www.onestein.eu>)
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from . import test_onchange_product_id

+ 0 - 106
tests/test_onchange_product_id.py

@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2016 Onestein (<http://www.onestein.eu>)
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from openerp.tests.common import TransactionCase
-
-
-class TestOnchangeProductId(TransactionCase):
-    """Test that when an included tax is mapped by a fiscal position,
-    the included tax must be subtracted to the price of the product.
-    """
-
-    def setUp(self):
-        super(TestOnchangeProductId, self).setUp()
-        curr_obj = self.env['res.currency']
-        self.eur = curr_obj.search([('name', '=', 'EUR')], limit=1).id
-        self.usd = curr_obj.search([('name', '=', 'USD')], limit=1).id
-        self.product = self.env['product.product'].create({
-            'name': 'Test Product',
-            'lst_price': 10.00,
-        })
-        version_dict1 = {
-            'name': 'Test version 1',
-            'items_id': [
-                (0, 0, {
-                    'name': 'Test item default',
-                    'base': 1,
-                    'price_discount': 0.1, })]
-        }
-        version_dict2 = {
-            'name': 'Test version 2',
-            'items_id': [
-                (0, 0, {
-                    'name': 'Test item default',
-                    'base': 1,
-                    'price_discount': 0.2, })]
-        }
-        self.plist1 = self.env['product.pricelist'].create(
-            {'name': 'Test pricelist 1',
-             'type': 'sale',
-             'currency_id': self.usd,
-             'version_id': [(0, 0, version_dict1)]})
-        self.plist2 = self.env['product.pricelist'].create(
-            {'name': 'Test pricelist 2',
-             'type': 'sale',
-             'currency_id': self.usd,
-             'version_id': [(0, 0, version_dict2)]})
-        self.partner = self.env['res.partner'].create(
-            {'name': 'Test partner',
-             'property_product_pricelist': self.plist1.id})
-        self.invoice_line = self.env['account.invoice.line'].create(
-            {'name': 'Test line',
-             'quantity': 1.0,
-             'price_unit': 1.0})
-
-    def test_onchange_product_id_pricelist(self):
-
-        currency = self.env['res.currency'].browse(self.eur)
-        rate = currency.rate_silent
-        price_unit = currency.round(10.00 * rate)
-        exp_value = currency.round((11.00 * rate))
-        res = self.invoice_line.product_id_change(
-            self.product.id, self.product.uom_id.id, qty=1.0,
-            partner_id=self.partner.id, currency_id=self.eur,
-            price_unit=price_unit,
-            company_id=self.env.user.company_id.id)
-
-        self.assertLessEqual(
-            abs(exp_value - res['value']['price_unit']), 0.0001,
-            "ERROR in getting price from pricelist")
-
-    def test_onchange_product_id_invoice_pricelist(self):
-
-        currency = self.env['res.currency'].browse(self.usd)
-        rate = currency.rate_silent
-        price_unit = currency.round(10.00 * rate)
-        exp_value = currency.round((12.00 * rate))
-        res = (
-            self.invoice_line
-            .with_context({'pricelist_id': self.plist2.id})
-            .product_id_change(
-                self.product.id, self.product.uom_id.id, qty=1.0,
-                partner_id=self.partner.id, currency_id=self.usd,
-                price_unit=price_unit,
-                company_id=self.env.user.company_id.id)
-        )
-
-        self.assertLessEqual(
-            abs(exp_value - res['value']['price_unit']), 0.0001,
-            "ERROR in getting price from pricelist")
-
-    def test_onchange_product_id_different_currency(self):
-
-        currency = self.env['res.currency'].browse(self.usd)
-        rate = currency.rate_silent
-        price_unit = currency.round(10.00 * rate)
-        exp_value = currency.round((11.00 * rate))
-        res = self.invoice_line.product_id_change(
-            self.product.id, self.product.uom_id.id, qty=1.0,
-            partner_id=self.partner.id, currency_id=self.usd,
-            price_unit=price_unit,
-            company_id=self.env.user.company_id.id)
-
-        self.assertLessEqual(
-            abs(exp_value - res['value']['price_unit']), 0.0001,
-            "ERROR in getting price from pricelist")

+ 2 - 2
views/account_invoice.xml

@@ -8,7 +8,7 @@
             <field name="inherit_id" ref="account.invoice_form"/>
             <field name="inherit_id" ref="account.invoice_form"/>
             <field name="arch" type="xml">
             <field name="arch" type="xml">
                 <xpath expr="//field[@name='fiscal_position']" position="after">
                 <xpath expr="//field[@name='fiscal_position']" position="after">
-                    <field name="pricelist_id" domain="[('type','=','sale')]"/>
+                    <field name="pricelist_id" domain="[('type','=','sale'),('active','=',True)]" groups="product.group_sale_pricelist" attrs="{'readonly':[('state','!=','draft')]}" string="Lista de precios"/>
                 </xpath>
                 </xpath>
                 <xpath expr="//field[@name='invoice_line']/tree/field[@name='product_id']" position="attributes">
                 <xpath expr="//field[@name='invoice_line']/tree/field[@name='product_id']" position="attributes">
                     <attribute name="context">{'type': type, 'pricelist_id': parent.pricelist_id}</attribute>
                     <attribute name="context">{'type': type, 'pricelist_id': parent.pricelist_id}</attribute>
@@ -26,7 +26,7 @@
             <field name="inherit_id" ref="account.invoice_supplier_form"/>
             <field name="inherit_id" ref="account.invoice_supplier_form"/>
             <field name="arch" type="xml">
             <field name="arch" type="xml">
                 <xpath expr="//field[@name='fiscal_position']" position="after">
                 <xpath expr="//field[@name='fiscal_position']" position="after">
-                    <field name="pricelist_id" domain="[('type','=','sale')]"/>
+                    <field name="pricelist_id" domain="[('type','=','purchase'),('active','=',True)]" groups="product.group_purchase_pricelist"  attrs="{'readonly':[('state','!=','draft')]}" string="Lista de precios"/>
                 </xpath>
                 </xpath>
                 <xpath expr="//field[@name='invoice_line']/tree/field[@name='product_id']" position="attributes">
                 <xpath expr="//field[@name='invoice_line']/tree/field[@name='product_id']" position="attributes">
                     <attribute name="context">{'type': type, 'pricelist_id': parent.pricelist_id}</attribute>
                     <attribute name="context">{'type': type, 'pricelist_id': parent.pricelist_id}</attribute>