Skip to content

Commit

Permalink
[REF] l10n_ve_withholding_src: Include data demo to manifest file and…
Browse files Browse the repository at this point in the history
… update method onchange_partner_id to v8
  • Loading branch information
suniagajose committed Dec 17, 2015
1 parent 7261d38 commit 78c6d77
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 2 additions & 0 deletions l10n_ve_withholding/model/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def ret_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id,
writeoff_period_id, writeoff_journal_id, date,
name, context=context)

# TODO: check the method _get_move_lines that is forced to return []
# and that makes that aws_customer.yml test cause a error
if not l2:
raise osv.except_osv(
_('Warning !'),
Expand Down
6 changes: 6 additions & 0 deletions l10n_ve_withholding_src/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@
'report/wh_src_report.xml',

],
'demo': [
"demo/demo_accounts.xml",
"demo/demo_company.xml",
"demo/demo_journals.xml",
],

"installable": True,
}
28 changes: 14 additions & 14 deletions l10n_ve_withholding_src/model/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################

from openerp import api
from openerp.addons import decimal_precision as dp
from openerp.osv import fields, osv
from openerp.tools.translate import _
Expand All @@ -31,7 +32,8 @@
class AccountInvoice(osv.osv):
_inherit = 'account.invoice'

def onchange_partner_id(self, cr, uid, ids, inv_type, partner_id,
@api.multi
def onchange_partner_id(self, inv_type, partner_id,
date_invoice=False, payment_term=False,
partner_bank_id=False, company_id=False):
""" Change invoice information depending of the partner
Expand All @@ -42,22 +44,20 @@ def onchange_partner_id(self, cr, uid, ids, inv_type, partner_id,
@param partner_bank_id: Partner bank id of the invoice
@param company_id: Company id
"""
rp_obj = self.pool.get('res.partner')
partner = self.env['res.partner']
res = super(AccountInvoice, self).onchange_partner_id(
cr, uid, ids, inv_type, partner_id, date_invoice, payment_term,
inv_type, partner_id, date_invoice, payment_term,
partner_bank_id, company_id)

if inv_type in ('out_invoice',):
rp_brw = rp_obj._find_accounting_partner(
rp_obj.browse(cr, uid, partner_id))
res['value']['wh_src_rate'] = rp_brw.wh_src_agent and \
rp_brw.wh_src_rate or 0
if inv_type in ('out_invoice'):
acc_partner = partner._find_accounting_partner(
partner.browse(partner_id))
res['value']['wh_src_rate'] = acc_partner.wh_src_agent and \
acc_partner.wh_src_rate or 0
else:
ru_brw = self.pool.get('res.users').browse(cr, uid, uid)
rp_brw = rp_obj._find_accounting_partner(
ru_brw.company_id.partner_id)
res['value']['wh_src_rate'] = rp_brw.wh_src_agent and \
rp_brw.wh_src_rate or 0
acc_partner = partner._find_accounting_partner(
self.env.user.company_id.partner_id)
res['value']['wh_src_rate'] = acc_partner.wh_src_agent and \
acc_partner.wh_src_rate or 0
return res

def _check_retention(self, cr, uid, ids, context=None):
Expand Down
2 changes: 1 addition & 1 deletion l10n_ve_withholding_src/model/wh_src.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def action_move_create(self, cr, uid, ids, context=None):
if context is None:
context = {}

context.update({'wh_src': True})
dict(context).update({'wh_src': True})

ret = self.browse(cr, uid, ids[0], context)

Expand Down
2 changes: 1 addition & 1 deletion l10n_ve_withholding_src/test/aws_customer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
company_id: base.main_company
currency_id: base.EUR
journal_id: withholding_src_sale_journal
partner_id: l10n_ve_fiscal_requirements.f_req_partner_6
partner_id: l10n_ve_fiscal_requirements.f_req_partner_6
type: 'out_invoice'
number: '0908070605'
-
Expand Down

0 comments on commit 78c6d77

Please sign in to comment.