Account vouchers don't change period to the right company

Bug #1043857 reported by Leonardo Santagada @ Proge.com.br
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
In Progress
Medium
OpenERP R&D Addons Team 3

Bug Description

When changing the company on a voucher it doesn't set the correct period for that voucher, so it will not be able to generate the move.lines necessary latter, I attached a patch for it (I can create a branch and submit a pull request if it is preferable):

=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2012-08-28 10:58:11 +0000
+++ account_voucher/account_voucher.py 2012-08-30 14:02:12 +0000
@@ -705,6 +705,16 @@
                 res[key].update(vals[key])
         return res

+ def onchange_company_id(self, cr, uid, ids, company_id, date, context=None):
+ if context is None:
+ context ={}
+ ctx = context.copy()
+ ctx.update({'company_id': company_id})
+ period_pool = self.pool.get('account.period')
+ pids = period_pool.find(cr, uid, date, context=ctx)
+ if pids:
+ return {'value': {'period_id': pids[0]}}
+
     def onchange_date(self, cr, uid, ids, date, currency_id, payment_rate_currency_id, amount, company_id, context=None):
         """
         @param date: latest value from user input for field date

=== modified file 'account_voucher/account_voucher_view.xml'
--- account_voucher/account_voucher_view.xml 2012-01-31 13:36:57 +0000
+++ account_voucher/account_voucher_view.xml 2012-08-28 22:27:44 +0000
@@ -47,7 +47,7 @@
                         <field name="journal_id" widget="selection" select="1" on_change="onchange_journal_voucher(line_ids, tax_id, amount, partner_id, journal_id, type)"/>
                         <field name="type" required="1"/>
                         <field name="name" colspan="2"/>
- <field name="company_id" widget="selection" groups="base.group_multi_company"/>
+ <field name="company_id" widget="selection" on_change="onchange_company_id(company_id, date)" groups="base.group_multi_company"/>
                         <field name="reference" select="1"/>
                         <field name="account_id" widget="selection" invisible="True"/>
                     </group>

=== modified file 'account_voucher/voucher_payment_receipt_view.xml'
--- account_voucher/voucher_payment_receipt_view.xml 2012-01-31 13:36:57 +0000
+++ account_voucher/voucher_payment_receipt_view.xml 2012-08-28 22:50:47 +0000
@@ -156,7 +156,7 @@
                         <field name="date" select="1" invisible="context.get('line_type', False)" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id, context)"/>
                         <field name="reference" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
                         <field name="name" colspan="2" invisible="context.get('line_type', False)"/>
- <field name="company_id" widget="selection" groups="base.group_multi_company"/>
+ <field name="company_id" widget="selection" groups="base.group_multi_company" on_change="onchange_company_id(company_id, date)"/>
                         <field name="account_id"
                             widget="selection"
                             invisible="True"/>
@@ -309,7 +309,7 @@
                         <field name="date" select="1" invisible="context.get('line_type', False)" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id, context)"/>
                         <field name="reference" select="1" invisible="context.get('line_type', False)" string="Payment Ref"/>
                         <field name="name" colspan="2" invisible="context.get('line_type', False)"/>
- <field name="company_id" widget="selection" groups="base.group_multi_company"/>
+ <field name="company_id" widget="selection" groups="base.group_multi_company" on_change="onchange_company_id(company_id, date)"/>
                         <field name="account_id"
                             widget="selection"
                             invisible="True"/>

Tags: voucher

Related branches

Revision history for this message
Amit Parik (amit-parik) wrote :

Faced the same problem , Company as well both doesn't changed.

Thank god bug report!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Amit Parik (amit-parik) wrote :

good*

Revision history for this message
Leonardo Santagada @ Proge.com.br (santagada-proge) wrote :
Revision history for this message
Leonardo Santagada (santagada) wrote :
Revision history for this message
Josse Colpaert (OpenERP) (jco-openerp) wrote :

I am changing in trunk. It might be better not being able to change the company_id at all and have the company_id of the invoice by default.

Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
status: In Progress → Confirmed
Revision history for this message
Josse Colpaert (OpenERP) (jco-openerp) wrote :

Actually, changing the company_id has also repercussions on the journal_id to be exact. In the case of "Register payment" from an invoice, I made the company read-only, but then again there is a domain on the journal_id.

Changed in openobject-addons:
status: Confirmed → In Progress
Amit Parik (amit-parik)
tags: added: voucher
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.