Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					eab8349aee | 
							
								
								
									
										25
									
								
								invoice.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								invoice.py
									
									
									
									
									
								
							@@ -1,10 +1,10 @@
 | 
				
			|||||||
# This file is part of Tryton.  The COPYRIGHT file at the top level of
 | 
					# This file is part of Tryton.  The COPYRIGHT file at the top level of
 | 
				
			||||||
# this repository contains the full copyright notices and license terms.
 | 
					# this repository contains the full copyright notices and license terms.
 | 
				
			||||||
from trytond.pool import PoolMeta
 | 
					from trytond.pool import Pool, PoolMeta
 | 
				
			||||||
from trytond.model import fields
 | 
					from trytond.model import ModelView, ModelSQL, fields
 | 
				
			||||||
from trytond.pyson import Eval
 | 
					from trytond.pyson import Eval
 | 
				
			||||||
from trytond.model.exceptions import ValidationError
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from trytond.exceptions import UserError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Invoice(metaclass=PoolMeta):
 | 
					class Invoice(metaclass=PoolMeta):
 | 
				
			||||||
    'Account Invoice'
 | 
					    'Account Invoice'
 | 
				
			||||||
@@ -14,8 +14,8 @@ class Invoice(metaclass=PoolMeta):
 | 
				
			|||||||
        'readonly': Eval('state') != 'draft',
 | 
					        'readonly': Eval('state') != 'draft',
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    account_analytic = fields.Many2One(
 | 
					
 | 
				
			||||||
        'analytic_account.account', 'Analytic Account',
 | 
					    account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account',
 | 
				
			||||||
                                       domain=[('type', '=', 'normal')],
 | 
					                                       domain=[('type', '=', 'normal')],
 | 
				
			||||||
                                       states=_states)
 | 
					                                       states=_states)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -24,19 +24,16 @@ class InvoiceLine(metaclass=PoolMeta):
 | 
				
			|||||||
      'Invoice Line'
 | 
					      'Invoice Line'
 | 
				
			||||||
      __name__ = 'account.invoice.line'
 | 
					      __name__ = 'account.invoice.line'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @fields.depends(
 | 
					      @fields.depends('product', 'unit', '_parent_invoice.type', 'analytic_accounts',
 | 
				
			||||||
        'product', 'unit', '_parent_invoice.type', 'analytic_accounts',
 | 
					 | 
				
			||||||
                      '_parent_invoice.party', 'party', 'invoice', 'invoice_type',
 | 
					                      '_parent_invoice.party', 'party', 'invoice', 'invoice_type',
 | 
				
			||||||
                      '_parent_invoice.account_analytic', '_parent_invoice.invoice_date',
 | 
					                      '_parent_invoice.account_analytic', '_parent_invoice.invoice_date',
 | 
				
			||||||
        '_parent_invoice.accounting_date', 'company',
 | 
					                      '_parent_invoice.accounting_date','company', methods=['_get_tax_rule_pattern'])
 | 
				
			||||||
        methods=['_get_tax_rule_pattern'])
 | 
					 | 
				
			||||||
      def on_change_product(self):
 | 
					      def on_change_product(self):
 | 
				
			||||||
          super(InvoiceLine, self).on_change_product()
 | 
					          super(InvoiceLine, self).on_change_product()
 | 
				
			||||||
          self.analytic_accounts = tuple()
 | 
					          self.analytic_accounts = tuple()
 | 
				
			||||||
          try:
 | 
					          try:
 | 
				
			||||||
            if self.invoice and self.invoice.account_analytic:
 | 
					              self.analytic_accounts += ({'root': self.invoice.account_analytic.root,
 | 
				
			||||||
                self.analytic_accounts += (
 | 
					 | 
				
			||||||
                    {'root': self.invoice.account_analytic.root,
 | 
					 | 
				
			||||||
                                          'account': self.invoice.account_analytic},) 
 | 
					                                          'account': self.invoice.account_analytic},) 
 | 
				
			||||||
        except Exception as e:
 | 
					          except:
 | 
				
			||||||
            raise ValidationError(f"Se produjo un error: {e}")
 | 
					              pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								purchase.py
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								purchase.py
									
									
									
									
									
								
							@@ -1,10 +1,10 @@
 | 
				
			|||||||
# This file is part of Tryton.  The COPYRIGHT file at the top level of
 | 
					# This file is part of Tryton.  The COPYRIGHT file at the top level of
 | 
				
			||||||
# this repository contains the full copyright notices and license terms.
 | 
					# this repository contains the full copyright notices and license terms.
 | 
				
			||||||
from trytond.pool import PoolMeta
 | 
					from trytond.pool import Pool, PoolMeta
 | 
				
			||||||
from trytond.model import fields
 | 
					from trytond.model import ModelView, ModelSQL, fields
 | 
				
			||||||
from trytond.pyson import Eval
 | 
					from trytond.pyson import Eval
 | 
				
			||||||
from trytond.model.exceptions import ValidationError
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from trytond.exceptions import UserError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Purchase(metaclass=PoolMeta):
 | 
					class Purchase(metaclass=PoolMeta):
 | 
				
			||||||
    'Purchase Analytic Operation'
 | 
					    'Purchase Analytic Operation'
 | 
				
			||||||
@@ -14,22 +14,17 @@ class Purchase(metaclass=PoolMeta):
 | 
				
			|||||||
        'readonly': Eval('state') != 'draft',
 | 
					        'readonly': Eval('state') != 'draft',
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    account_analytic = fields.Many2One(
 | 
					    account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account', required=True,
 | 
				
			||||||
        'analytic_account.account', 'Analytic Account', required=True,
 | 
					 | 
				
			||||||
                                       domain=[('type', '=', 'normal')],
 | 
					                                       domain=[('type', '=', 'normal')],
 | 
				
			||||||
                                       states=_states)
 | 
					                                       states=_states)
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class PurchaseLine(metaclass=PoolMeta):
 | 
					class PurchaseLine(metaclass=PoolMeta):
 | 
				
			||||||
    'Purchase Line Analytic Operation'
 | 
					    'Purchase Line Analytic Operation'
 | 
				
			||||||
    __name__ =  'purchase.line'
 | 
					    __name__ =  'purchase.line'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @fields.depends(
 | 
					    @fields.depends('product', 'unit', 'purchase',
 | 
				
			||||||
        'product', 'unit', 'purchase',
 | 
					 | 
				
			||||||
        '_parent_purchase.party', '_parent_purchase.invoice_party',
 | 
					        '_parent_purchase.party', '_parent_purchase.invoice_party',
 | 
				
			||||||
        '_parent_purchase.account_analytic', 'product_supplier',
 | 
					        '_parent_purchase.account_analytic', 'product_supplier',
 | 
				
			||||||
        'analytic_accounts',
 | 
					        'analytic_accounts', methods=['compute_taxes', 'compute_unit_price',
 | 
				
			||||||
        methods=['compute_taxes', 'compute_unit_price',
 | 
					 | 
				
			||||||
                                     '_get_product_supplier_pattern'])
 | 
					                                     '_get_product_supplier_pattern'])
 | 
				
			||||||
    def on_change_product(self):
 | 
					    def on_change_product(self):
 | 
				
			||||||
        if not self.product:
 | 
					        if not self.product:
 | 
				
			||||||
@@ -62,8 +57,7 @@ class PurchaseLine(metaclass=PoolMeta):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        self.analytic_accounts = tuple()
 | 
					        self.analytic_accounts = tuple()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.analytic_accounts += (
 | 
					            self.analytic_accounts += ({'root': self.purchase.account_analytic.root,
 | 
				
			||||||
                {'root': self.purchase.account_analytic.root,
 | 
					 | 
				
			||||||
                                        'account': self.purchase.account_analytic},) 
 | 
					                                        'account': self.purchase.account_analytic},) 
 | 
				
			||||||
        except Exception as e:
 | 
					        except:
 | 
				
			||||||
            raise ValidationError(f"Se produjo un error: {e}")
 | 
					            pass
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								sale.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								sale.py
									
									
									
									
									
								
							@@ -1,9 +1,10 @@
 | 
				
			|||||||
# This file is part of Tryton.  The COPYRIGHT file at the top level of
 | 
					# This file is part of Tryton.  The COPYRIGHT file at the top level of
 | 
				
			||||||
# this repository contains the full copyright notices and license terms.
 | 
					# this repository contains the full copyright notices and license terms.
 | 
				
			||||||
from trytond.pool import PoolMeta
 | 
					from trytond.pool import Pool, PoolMeta
 | 
				
			||||||
from trytond.model import fields
 | 
					from trytond.model import ModelView, ModelSQL, fields
 | 
				
			||||||
from trytond.model.exceptions import ValidationError
 | 
					from trytond.pyson import Eval
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from trytond.exceptions import UserError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Sale(metaclass=PoolMeta):
 | 
					class Sale(metaclass=PoolMeta):
 | 
				
			||||||
    'Sale Analytic Operation'
 | 
					    'Sale Analytic Operation'
 | 
				
			||||||
@@ -15,11 +16,12 @@ class Sale(metaclass=PoolMeta):
 | 
				
			|||||||
                                           ('type', '=', 'normal'),
 | 
					                                           ('type', '=', 'normal'),
 | 
				
			||||||
                                       ])
 | 
					                                       ])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class SaleLine(metaclass=PoolMeta):
 | 
					class SaleLine(metaclass=PoolMeta):
 | 
				
			||||||
    'Sale Line Analytic Operation'
 | 
					    'Sale Line Analytic Operation'
 | 
				
			||||||
    __name__ =  'sale.line'
 | 
					    __name__ =  'sale.line'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @fields.depends('product', 'unit', 'sale',
 | 
					    @fields.depends('product', 'unit', 'sale',
 | 
				
			||||||
                    '_parent_sale.party', '_parent_sale.invoice_party',
 | 
					                    '_parent_sale.party', '_parent_sale.invoice_party',
 | 
				
			||||||
                    '_parent_sale.account_analytic', 'analytic_accounts',
 | 
					                    '_parent_sale.account_analytic', 'analytic_accounts',
 | 
				
			||||||
@@ -42,13 +44,13 @@ class SaleLine(metaclass=PoolMeta):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        self.unit_price = self.compute_unit_price()
 | 
					        self.unit_price = self.compute_unit_price()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.type = 'line'
 | 
					        self.type = 'line'
 | 
				
			||||||
        self.amount = self.on_change_with_amount()
 | 
					        self.amount = self.on_change_with_amount()
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        self.analytic_accounts = tuple()
 | 
					        self.analytic_accounts = tuple()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.analytic_accounts += (
 | 
					            self.analytic_accounts += ({'root': self.sale.account_analytic.root,
 | 
				
			||||||
                {'root': self.sale.account_analytic.root,
 | 
					 | 
				
			||||||
                                        'account': self.sale.account_analytic},) 
 | 
					                                        'account': self.sale.account_analytic},) 
 | 
				
			||||||
        except Exception as e:
 | 
					        except:
 | 
				
			||||||
            raise ValidationError(f"Se produjo un error: {e}")
 | 
					            pass
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								setup.py
									
									
									
									
									
								
							@@ -39,7 +39,7 @@ version = info.get('version', '0.0.1')
 | 
				
			|||||||
major_version, minor_version, _ = version.split('.', 2)
 | 
					major_version, minor_version, _ = version.split('.', 2)
 | 
				
			||||||
major_version = int(major_version)
 | 
					major_version = int(major_version)
 | 
				
			||||||
minor_version = int(minor_version)
 | 
					minor_version = int(minor_version)
 | 
				
			||||||
name = 'trytond_analytic_operations'
 | 
					name = 'trytond_analytic_operation'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
download_url = 'http://downloads.tryton.org/%s.%s/' % (
 | 
					download_url = 'http://downloads.tryton.org/%s.%s/' % (
 | 
				
			||||||
    major_version, minor_version)
 | 
					    major_version, minor_version)
 | 
				
			||||||
@@ -85,20 +85,19 @@ setup(name=name,
 | 
				
			|||||||
    download_url=download_url,
 | 
					    download_url=download_url,
 | 
				
			||||||
    project_urls={
 | 
					    project_urls={
 | 
				
			||||||
        "Bug Tracker": 'https://bugs.tryton.org/',
 | 
					        "Bug Tracker": 'https://bugs.tryton.org/',
 | 
				
			||||||
        "Documentation":
 | 
					        "Documentation": 'https://docs.tryton.org/projects/modules-analytic-operation',
 | 
				
			||||||
            'https://docs.tryton.org/projects/modules-analytic-operation',
 | 
					 | 
				
			||||||
        "Forum": 'https://www.tryton.org/forum',
 | 
					        "Forum": 'https://www.tryton.org/forum',
 | 
				
			||||||
        "Source Code": 'https://hg.tryton.org/modules/analytic_operations',
 | 
					        "Source Code": 'https://hg.tryton.org/modules/analytic_operation',
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    keywords='analitic, invoice, purchase, sale',
 | 
					    keywords='analitic, invoice, purchase, sale',
 | 
				
			||||||
    package_dir={'trytond.modules.analytic_operations': '.'},
 | 
					    package_dir={'trytond.modules.analytic_operation': '.'},
 | 
				
			||||||
    packages=(
 | 
					    packages=(
 | 
				
			||||||
        ['trytond.modules.analytic_operations']
 | 
					        ['trytond.modules.analytic_operation']
 | 
				
			||||||
        + ['trytond.modules.analytic_operations.%s' % p
 | 
					        + ['trytond.modules.analytic_operation.%s' % p
 | 
				
			||||||
            for p in find_packages()]
 | 
					            for p in find_packages()]
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
    package_data={
 | 
					    package_data={
 | 
				
			||||||
        'trytond.modules.analytic_operations': (info.get('xml', [])
 | 
					        'trytond.modules.analytic_operation': (info.get('xml', [])
 | 
				
			||||||
            + ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
 | 
					            + ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
 | 
				
			||||||
                'icons/*.svg', 'tests/*.rst']),
 | 
					                'icons/*.svg', 'tests/*.rst']),
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@@ -151,6 +150,6 @@ setup(name=name,
 | 
				
			|||||||
    zip_safe=False,
 | 
					    zip_safe=False,
 | 
				
			||||||
    entry_points="""
 | 
					    entry_points="""
 | 
				
			||||||
    [trytond.modules]
 | 
					    [trytond.modules]
 | 
				
			||||||
    analytic_operations = trytond.modules.analytic_operations
 | 
					    analytic_operation = trytond.modules.analytic_operation
 | 
				
			||||||
    """,  # noqa: E501
 | 
					    """,  # noqa: E501
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ from trytond.tests.test_tryton import ModuleTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class AnalyticOperationTestCase(ModuleTestCase):
 | 
					class AnalyticOperationTestCase(ModuleTestCase):
 | 
				
			||||||
    "Test Analytic Operation module"
 | 
					    "Test Analytic Operation module"
 | 
				
			||||||
    module = 'analytic_operations'
 | 
					    module = 'analytic_operation'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
del ModuleTestCase
 | 
					del ModuleTestCase
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tox.ini
									
									
									
									
									
								
							@@ -4,8 +4,8 @@ envlist = {py37,py38,py39,py310}-{sqlite,postgresql}
 | 
				
			|||||||
[testenv]
 | 
					[testenv]
 | 
				
			||||||
extras = test
 | 
					extras = test
 | 
				
			||||||
commands =
 | 
					commands =
 | 
				
			||||||
    coverage run --include=./**//* -m unittest discover -s tests
 | 
					    coverage run --include=./**/analytic_operation/* -m unittest discover -s tests
 | 
				
			||||||
    coverage report --include=./**/analytic_operations/* --omit=*/tests/*
 | 
					    coverage report --include=./**/analytic_operation/* --omit=*/tests/*
 | 
				
			||||||
deps =
 | 
					deps =
 | 
				
			||||||
    coverage
 | 
					    coverage
 | 
				
			||||||
    postgresql: psycopg2 >= 2.7.0
 | 
					    postgresql: psycopg2 >= 2.7.0
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
[tryton]
 | 
					[tryton]
 | 
				
			||||||
version=7.6.0
 | 
					version=7.0.0
 | 
				
			||||||
depends:
 | 
					depends:
 | 
				
			||||||
    ir
 | 
					    ir
 | 
				
			||||||
    purchase
 | 
					    purchase
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user