_sql_constraints = [
('name_uniq', 'unique (name)', 'The company name must be unique !')
]
- def on_change_header(self, cr, uid, ids, phone, email, fax, website, vat, reg=False, context=None):
- val = []
- if phone: val.append(_('Phone: ')+phone)
- if fax: val.append(_('Fax: ')+fax)
- if website: val.append(_('Website: ')+website)
- if vat: val.append(_('TIN: ')+vat)
- if reg: val.append(_('Reg: ')+reg)
- return {'value': {'rml_footer1':' | '.join(val)}}
-
+
+ def on_change_footer(self, cr, uid, ids, custom_footer, phone, email, fax,
+ website, vat, company_registry, bank_ids, context=None):
+ if custom_footer:
+ return {}
+
+ # first line (notice that missing elements are filtered out before the join)
+ res = ' | '.join(filter(bool, [
+ phone and '%s: %s' % (_('Phone'), phone),
+ fax and '%s: %s' % (_('Fax'), fax),
+ email and '%s: %s' % (_('Email'), email),
+ website and '%s: %s' % (_('Website'), website),
+ vat and '%s: %s' % (_('TIN'), vat),
+ company_registry and '%s: %s' % (_('Reg'), company_registry),
+ ]))
+
+ # second line: bank accounts
+ accounts = self.resolve_2many_commands(cr, uid, 'bank_ids', bank_ids, context=context)
+ accounts_names = [('%(bank_name)s %(acc_number)s' % acc) for acc in accounts if acc['footer']]
+ if accounts_names:
+ title = _('Bank Accounts') if len(accounts_names) > 1 else _('Bank Account')
+ res += '\n%s: %s' % (title, ', '.join(accounts_names))
+
+ return {'value': {'rml_footer': res, 'rml_footer_readonly': res}}
+
+ def _get_rml_footer_by_line(self, cr, uid, ids, rml_footer, line, context=None):
+ rml_footer_lines = (rml_footer or '').split('\n')
+ return rml_footer_lines[line] if line < len(rml_footer_lines) else ''
+
+ def on_change_country(self, cr, uid, ids, country_id, context=None):
+ currency_id = self._get_euro(cr, uid, context=context)
+ if country_id:
+ currency_id = self.pool.get('res.country').browse(cr, uid, country_id, context=context).currency_id.id
+ return {'value': {'currency_id': currency_id}}
+
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False, access_rights_uid=None):
if context is None:
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%" options='{"no_open": true}'/>
<field name="zip" placeholder="ZIP" style="width: 34%%"/>
</div>
- <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": true}'/>
+ <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": true}' on_change="on_change_country(country_id)"/>
</div>
- <field name="website" widget="url" placeholder="e.g. www.openerp.com"/>
+ <label for="rml_header1"/>
+ <div>
+ <field name="rml_header1" placeholder="e.g. Global Business Solutions"/>
+ </div>
+ <field name="website" on_change="on_change_footer(custom_footer, phone, email, fax, website, vat, company_registry, bank_ids)" widget="url" placeholder="e.g. www.openerp.com"/>
</group>
<group>
- <field name="phone" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
- <field name="fax" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
- <field name="email" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
- <field name="vat" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
- <field name="company_registry" on_change="on_change_header(phone, email, fax, website, vat, company_registry)"/>
+ <field name="phone" on_change="on_change_footer(custom_footer, phone, email, fax, website, vat, company_registry, bank_ids)"/>
+ <field name="fax" on_change="on_change_footer(custom_footer, phone, email, fax, website, vat, company_registry, bank_ids)"/>
+ <field name="email" on_change="on_change_footer(custom_footer, phone, email, fax, website, vat, company_registry, bank_ids)"/>
+ <field name="vat" on_change="on_change_footer(custom_footer, phone, email, fax, website, vat, company_registry, bank_ids)"/>
+ <field name="company_registry" on_change="on_change_footer(custom_footer, phone, email, fax, website, vat, company_registry, bank_ids)"/>
</group>
</group>
<group string="Bank Accounts">