Browse Source

[12.0][REF] - Contract Variable quantity: split from analytic accoun

pull/238/head
sbejaoui 5 years ago
parent
commit
d42b14667e
  1. 11
      contract_variable_quantity/__manifest__.py
  2. 32
      contract_variable_quantity/migrations/12.0.2.0.0/pre-migration.py
  3. 4
      contract_variable_quantity/models/abstract_contract_line.py
  4. 4
      contract_variable_quantity/models/contract.py
  5. 2
      contract_variable_quantity/models/contract_line.py
  6. 4
      contract_variable_quantity/models/contract_line_formula.py
  7. 5
      contract_variable_quantity/tests/test_contract_variable_quantity.py
  8. 10
      contract_variable_quantity/views/abstract_contract_line.xml
  9. 6
      contract_variable_quantity/views/contract.xml
  10. 9
      contract_variable_quantity/views/contract_line.xml
  11. 12
      contract_variable_quantity/views/contract_template.xml

11
contract_variable_quantity/__manifest__.py

@ -1,10 +1,11 @@
# Copyright 2016-2018 Tecnativa - Pedro M. Baeza # Copyright 2016-2018 Tecnativa - Pedro M. Baeza
# Copyright 2018 Tecnativa - Carlos Dauden # Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Variable quantity in contract recurrent invoicing', 'name': 'Variable quantity in contract recurrent invoicing',
'version': '12.0.1.0.0',
'version': '12.0.2.0.0',
'category': 'Contract Management', 'category': 'Contract Management',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': "Tecnativa," 'author': "Tecnativa,"
@ -13,11 +14,11 @@
'depends': ['contract'], 'depends': ['contract'],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/abstract_contract_view.xml',
'views/abstract_contract_line.xml',
'views/contract_line_formula.xml', 'views/contract_line_formula.xml',
'views/contract_line_view.xml',
'views/contract_template_view.xml',
'views/contract_view.xml',
'views/contract_line.xml',
'views/contract_template.xml',
'views/contract.xml',
], ],
'installable': True, 'installable': True,
} }

32
contract_variable_quantity/migrations/12.0.2.0.0/pre-migration.py

@ -0,0 +1,32 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from openupgradelib import openupgrade
_logger = logging.getLogger(__name__)
def migrate(cr, version):
xmlids_to_rename = [
('contract_sale.account_analytic_account_own_salesman',
'contract_sale.contract_contract_own_salesman'),
('contract_sale.account_analytic_account_see_all',
'contract_sale.contract_contract_see_all'),
('contract_sale.account_analytic_contract_salesman',
'contract_sale.contract_template_salesman'),
('contract_sale.account_analytic_contract_sale_manager',
'contract_sale.contract_template_sale_manager'),
('contract_sale.account_analytic_invoice_line_saleman',
'contract_sale.contract_line_saleman'),
('contract_sale.account_analytic_invoice_line_manager',
'contract_sale.contract_line_manager'),
('contract_sale.account_analytic_contract_line_salesman',
'contract_sale.contract_template_line_salesman'),
('contract_sale.account_analytic_contract_line_manager',
'contract_sale.contract_template_line_manager'),
('contract_sale.account_analytic_account_contract_salesman',
'contract_sale.contract_contract_salesman'),
]
openupgrade.rename_xmlids(cr, xmlids_to_rename)

4
contract_variable_quantity/models/abstract_contract_line.py

@ -6,8 +6,8 @@
from odoo import fields, models from odoo import fields, models
class AccountAbstractAnalyticContractLine(models.AbstractModel):
_inherit = 'account.abstract.analytic.contract.line'
class ContractAbstractContractLine(models.AbstractModel):
_inherit = 'contract.abstract.contract.line'
qty_type = fields.Selection( qty_type = fields.Selection(
selection=[ selection=[

4
contract_variable_quantity/models/contract.py

@ -6,8 +6,8 @@
from odoo import fields, models from odoo import fields, models
class AccountAnalyticAccount(models.Model):
_inherit = "account.analytic.account"
class ContractContract(models.Model):
_inherit = "contract.contract"
skip_zero_qty = fields.Boolean( skip_zero_qty = fields.Boolean(
string='Skip Zero Qty Lines', string='Skip Zero Qty Lines',

2
contract_variable_quantity/models/contract_line.py

@ -9,7 +9,7 @@ from odoo.tools.safe_eval import safe_eval
class AccountAnalyticInvoiceLine(models.Model): class AccountAnalyticInvoiceLine(models.Model):
_inherit = 'account.analytic.invoice.line'
_inherit = 'contract.line'
@api.multi @api.multi
def _get_quantity_to_invoice( def _get_quantity_to_invoice(

4
contract_variable_quantity/models/contract_line_formula.py

@ -20,8 +20,8 @@ class ContractLineFormula(models.Model):
'env': self.env, 'env': self.env,
'context': self.env.context, 'context': self.env.context,
'user': self.env.user, 'user': self.env.user,
'line': self.env['account.analytic.invoice.line'],
'contract': self.env['account.analytic.account'],
'line': self.env['contract.line'],
'contract': self.env['contract.contract'],
'invoice': self.env['account.invoice'], 'invoice': self.env['account.invoice'],
'quantity': 0, 'quantity': 0,
'period_first_date': False, 'period_first_date': False,

5
contract_variable_quantity/tests/test_contract_variable_quantity.py

@ -16,12 +16,11 @@ class TestContractVariableQuantity(odoo.tests.HttpCase):
self.product = self.env['product.product'].create( self.product = self.env['product.product'].create(
{'name': 'Test product'} {'name': 'Test product'}
) )
self.contract = self.env['account.analytic.account'].create(
self.contract = self.env['contract.contract'].create(
{ {
'name': 'Test Contract', 'name': 'Test Contract',
'partner_id': self.partner.id, 'partner_id': self.partner.id,
'pricelist_id': self.partner.property_product_pricelist.id, 'pricelist_id': self.partner.property_product_pricelist.id,
'recurring_invoices': True,
} }
) )
self.formula = self.env['contract.line.qty.formula'].create( self.formula = self.env['contract.line.qty.formula'].create(
@ -40,7 +39,7 @@ class TestContractVariableQuantity(odoo.tests.HttpCase):
'result = 12', 'result = 12',
} }
) )
self.contract_line = self.env['account.analytic.invoice.line'].create(
self.contract_line = self.env['contract.line'].create(
{ {
'contract_id': self.contract.id, 'contract_id': self.contract.id,
'product_id': self.product.id, 'product_id': self.product.id,

10
contract_variable_quantity/views/abstract_contract_view.xml → contract_variable_quantity/views/abstract_contract_line.xml

@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="account_abstract_analytic_contract_line_view_form"
<record id="contract_abstract_contract_line_form_view"
model="ir.ui.view"> model="ir.ui.view">
<field name="name">Account Abstract Analytic Contract Line Form View
</field>
<field name="model">account.abstract.analytic.contract.line</field>
<field name="inherit_id"
ref="contract.account_abstract_analytic_contract_line_view_form"/>
<field name="name">Abstract Contract Line Form View</field>
<field name="model">contract.abstract.contract.line</field>
<field name="inherit_id" ref="contract.contract_abstract_contract_line_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='quantity']" position="before"> <xpath expr="//field[@name='quantity']" position="before">
<field name="qty_type"/> <field name="qty_type"/>

6
contract_variable_quantity/views/contract_view.xml → contract_variable_quantity/views/contract.xml

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="account_analytic_account_recurring_form_form" model="ir.ui.view">
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
<record id="contract_contract_form_view" model="ir.ui.view">
<field name="model">contract.contract</field>
<field name="inherit_id" ref="contract.contract_contract_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='code']" position="after"> <xpath expr="//field[@name='code']" position="after">
<field name="skip_zero_qty"/> <field name="skip_zero_qty"/>

9
contract_variable_quantity/views/contract_line_view.xml → contract_variable_quantity/views/contract_line.xml

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="account_analytic_invoice_line_view_tree"
model="ir.ui.view">
<field name="name">account.analytic.invoice.line.tree (in contract_variable_quantity)</field>
<field name="model">account.analytic.invoice.line</field>
<record id="contract_line_form_view" model="ir.ui.view">
<field name="name">contract.line.tree (in contract_variable_quantity)</field>
<field name="model">contract.line</field>
<field name="inherit_id" <field name="inherit_id"
ref="contract.account_analytic_invoice_line_view_tree"/>
ref="contract.contract_line_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='quantity']" position="before"> <xpath expr="//field[@name='quantity']" position="before">
<field name="qty_type"/> <field name="qty_type"/>

12
contract_variable_quantity/views/contract_template_view.xml → contract_variable_quantity/views/contract_template.xml

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="account_analytic_contract_view_form" model="ir.ui.view">
<record id="contract_template_form_view" model="ir.ui.view">
<field name="name">Contract Template Variable Qty</field> <field name="name">Contract Template Variable Qty</field>
<field name="model">account.analytic.contract</field>
<field name="inherit_id" ref="contract.account_analytic_contract_view_form"/>
<field name="model">contract.template</field>
<field name="inherit_id" ref="contract.contract_template_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="before">
<xpath expr="//field[@name='contract_line_ids']//field[@name='quantity']" position="before">
<field name="qty_type"/> <field name="qty_type"/>
</xpath> </xpath>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="after">
<xpath expr="//field[@name='contract_line_ids']//field[@name='quantity']" position="after">
<field name="qty_formula_id" <field name="qty_formula_id"
attrs="{'required': [('qty_type', '=', 'variable')], 'invisible': [('qty_type', '!=', 'variable')]}" attrs="{'required': [('qty_type', '=', 'variable')], 'invisible': [('qty_type', '!=', 'variable')]}"
/> />
</xpath> </xpath>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="attributes">
<xpath expr="//field[@name='contract_line_ids']//field[@name='quantity']" position="attributes">
<attribute name="attrs">{'required': [('qty_type', '=', 'fixed')], 'invisible': [('qty_type', '!=', 'fixed')]}</attribute> <attribute name="attrs">{'required': [('qty_type', '=', 'fixed')], 'invisible': [('qty_type', '!=', 'fixed')]}</attribute>
</xpath> </xpath>
</field> </field>
Loading…
Cancel
Save