Browse Source

[FIX+IMP] contract: Real fix to company_id missing + improvements

* company_id was empty because an onchange, not inheritance nor visibility
* Added multi-company group to company_id fields
* Added multi-company access rule to contract templates
* Fix double %% in XML dates that was causing an error
* When creating a contract, recurring_invoices is set by default
pull/127/head
Pedro M. Baeza 7 years ago
committed by Dave Lasley
parent
commit
f6ebe6e9c7
No known key found for this signature in database GPG Key ID: 7DDBA4BA81B934CF
  1. 3
      contract/__manifest__.py
  2. 6
      contract/models/account_analytic_account.py
  3. 10
      contract/security/contract_security.xml
  4. 7
      contract/views/account_analytic_account_view.xml
  5. 2
      contract/views/account_analytic_contract_view.xml

3
contract/__manifest__.py

@ -9,7 +9,7 @@
{ {
'name': 'Contracts Management - Recurring', 'name': 'Contracts Management - Recurring',
'version': '10.0.3.1.0',
'version': '10.0.3.2.0',
'category': 'Contract Management', 'category': 'Contract Management',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': "OpenERP SA, " 'author': "OpenERP SA, "
@ -20,6 +20,7 @@
'depends': ['base', 'account', 'analytic'], 'depends': ['base', 'account', 'analytic'],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'security/contract_security.xml',
'report/report_contract.xml', 'report/report_contract.xml',
'report/contract_views.xml', 'report/contract_views.xml',
'data/contract_cron.xml', 'data/contract_cron.xml',

6
contract/models/account_analytic_account.py

@ -61,15 +61,13 @@ class AccountAnalyticAccount(models.Model):
deletion ensures that any errant lines that are created are also deletion ensures that any errant lines that are created are also
deleted. deleted.
""" """
contract = self.contract_template_id contract = self.contract_template_id
if not contract:
return
for field_name, field in contract._fields.iteritems(): for field_name, field in contract._fields.iteritems():
if field.name == 'recurring_invoice_line_ids': if field.name == 'recurring_invoice_line_ids':
lines = self._convert_contract_lines(contract) lines = self._convert_contract_lines(contract)
self.recurring_invoice_line_ids = lines self.recurring_invoice_line_ids = lines
elif not any(( elif not any((
field.compute, field.related, field.automatic, field.compute, field.related, field.automatic,
field.readonly, field.company_dependent, field.readonly, field.company_dependent,

10
contract/security/contract_security.xml

@ -0,0 +1,10 @@
<odoo noupdate="1">
<record id="rule_contract_template_multi_company" model="ir.rule">
<field name="name">Contract template multi-company</field>
<field name="model_id" ref="model_account_analytic_contract"/>
<field name="global" eval="True"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</odoo>

7
contract/views/account_analytic_account_view.xml

@ -38,6 +38,7 @@
<field name="contract_template_id" colspan="4"/> <field name="contract_template_id" colspan="4"/>
<field name="journal_id"/> <field name="journal_id"/>
<field name="pricelist_id"/> <field name="pricelist_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<label for="recurring_interval"/> <label for="recurring_interval"/>
<div> <div>
<field name="recurring_interval" <field name="recurring_interval"
@ -119,11 +120,11 @@
<separator/> <separator/>
<filter name="not_finished" <filter name="not_finished"
string="Valid" string="Valid"
domain="['|', ('date_end', '=', False), ('date_end', '&gt;=', time.strftime('%%Y-%%m-%%d'))]"
domain="['|', ('date_end', '=', False), ('date_end', '&gt;=', time.strftime('%Y-%m-%d'))]"
/> />
<filter name="finished" <filter name="finished"
string="Finished" string="Finished"
domain="[('date_end', '&lt;', time.strftime('%%Y-%%m-%%d'))]"
domain="[('date_end', '&lt;', time.strftime('%Y-%m-%d'))]"
/> />
<group expand="0" string="Group By..."> <group expand="0" string="Group By...">
<filter string="Next Invoice" <filter string="Next Invoice"
@ -145,7 +146,7 @@
<field name="res_model">account.analytic.account</field> <field name="res_model">account.analytic.account</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="context">{'is_contract':1, 'search_default_not_finished':1, 'search_default_recurring_invoices':1}</field>
<field name="context">{'is_contract':1, 'search_default_not_finished':1, 'search_default_recurring_invoices':1, 'default_recurring_invoices': 1}</field>
<field name="search_view_id" ref="analytic.view_account_analytic_account_search"/> <field name="search_view_id" ref="analytic.view_account_analytic_account_search"/>
<field name="help" type="html"> <field name="help" type="html">
<p class="oe_view_nocontent_create"> <p class="oe_view_nocontent_create">

2
contract/views/account_analytic_contract_view.xml

@ -7,11 +7,11 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Contract Template"> <form string="Contract Template">
<group name="group_main"> <group name="group_main">
<field name="company_id" invisible="1" />
<field name="name" /> <field name="name" />
<group name="group_main_left"> <group name="group_main_left">
<field name="journal_id" /> <field name="journal_id" />
<field name="pricelist_id" /> <field name="pricelist_id" />
<field name="company_id" groups="base.group_multi_company"/>
</group> </group>
<group name="group_main_right"> <group name="group_main_right">
<field name="recurring_invoicing_type" /> <field name="recurring_invoicing_type" />

Loading…
Cancel
Save