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/202/head
Pedro M. Baeza 7 years ago
parent
commit
cb146a3aef
  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. 1
      contract/views/account_analytic_contract_view.xml

3
contract/__manifest__.py

@ -8,7 +8,7 @@
{ {
'name': 'Contracts Management - Recurring', 'name': 'Contracts Management - Recurring',
'version': '11.0.1.2.0',
'version': '11.0.1.3.0',
'category': 'Contract Management', 'category': 'Contract Management',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': "OpenERP SA, " 'author': "OpenERP SA, "
@ -19,6 +19,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

@ -71,15 +71,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.items(): for field_name, field in contract._fields.items():
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

@ -44,6 +44,7 @@
attrs="{'required': [('recurring_invoices', '=', True)]}" attrs="{'required': [('recurring_invoices', '=', True)]}"
/> />
<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"
@ -131,11 +132,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"
@ -157,7 +158,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">

1
contract/views/account_analytic_contract_view.xml

@ -12,6 +12,7 @@
<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