commit
1b0700fd2f
|
@ -170,7 +170,9 @@ class account_bank_statement(osv.osv):
|
|||
if line.state <> 'valid':
|
||||
raise osv.except_osv(_('Error !'),
|
||||
_('The account entries lines are not in valid state.'))
|
||||
|
||||
# for bank.statement.lines
|
||||
# In line we get reconcile_id on bank.ste.rec.
|
||||
# in bank stat.rec we get line_new_ids on bank.stat.rec.line
|
||||
for move in st.line_ids:
|
||||
move_id = account_move_obj.create(cr, uid, {
|
||||
'journal_id': st.journal_id.id,
|
||||
|
@ -209,7 +211,7 @@ class account_bank_statement(osv.osv):
|
|||
'period_id': st.period_id.id,
|
||||
'currency_id': st.currency.id,
|
||||
}
|
||||
|
||||
|
||||
amount = res_currency_obj.compute(cr, uid, st.currency.id,
|
||||
company_currency_id, move.amount, context=context,
|
||||
account=acc_cur)
|
||||
|
@ -245,6 +247,8 @@ class account_bank_statement(osv.osv):
|
|||
'statement_id': st.id,
|
||||
'journal_id': st.journal_id.id,
|
||||
'period_id': st.period_id.id,
|
||||
'analytic_account_id':newline.analytic_id and newline.analytic_id.id or False,
|
||||
|
||||
}, context=context)
|
||||
|
||||
# Fill the secondary amount/currency
|
||||
|
@ -491,10 +495,14 @@ class account_bank_statement_reconcile_line(osv.osv):
|
|||
_name = "account.bank.statement.reconcile.line"
|
||||
_description = "Statement reconcile line"
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64),
|
||||
'name': fields.char('Description', size=64, required=True),
|
||||
'account_id': fields.many2one('account.account', 'Account', required=True),
|
||||
'line_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile'),
|
||||
'amount': fields.float('Amount', required=True),
|
||||
'analytic_id': fields.many2one('account.analytic.account',"Analytic Account")
|
||||
}
|
||||
_defaults = {
|
||||
'name': lambda *a: 'Write-Off',
|
||||
}
|
||||
account_bank_statement_reconcile_line()
|
||||
|
||||
|
|
|
@ -351,8 +351,8 @@ class account_move_line(osv.osv):
|
|||
'quantity': fields.float('Quantity', digits=(16,2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very usefull for some reports."),
|
||||
'product_uom_id': fields.many2one('product.uom', 'UoM'),
|
||||
'product_id': fields.many2one('product.product', 'Product'),
|
||||
'debit': fields.float('Debit', digits=(16,2)),
|
||||
'credit': fields.float('Credit', digits=(16,2)),
|
||||
'debit': fields.float('Debit', digits=(16,int(tools.config['price_accuracy']))),
|
||||
'credit': fields.float('Credit', digits=(16,int(tools.config['price_accuracy']))),
|
||||
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
|
||||
'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly',True)]}, help="The move of this entry line.", select=2),
|
||||
|
||||
|
@ -360,7 +360,7 @@ class account_move_line(osv.osv):
|
|||
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
|
||||
'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2),
|
||||
'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2),
|
||||
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry."),
|
||||
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits=(16,int(tools.config['price_accuracy']))),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
|
||||
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, select=2),
|
||||
|
@ -379,14 +379,14 @@ class account_move_line(osv.osv):
|
|||
'balance': fields.function(_balance, fnct_search=_balance_search, method=True, string='Balance'),
|
||||
'state': fields.selection([('draft','Draft'), ('valid','Valid')], 'Status', readonly=True),
|
||||
'tax_code_id': fields.many2one('account.tax.code', 'Tax Account', help="The Account can either be a base tax code or tax code account."),
|
||||
'tax_amount': fields.float('Tax/Base Amount', digits=(16,2), select=True, help="If the Tax account is tax code account, this field will contain the taxed amount.If the tax account is base tax code,\
|
||||
'tax_amount': fields.float('Tax/Base Amount', digits=(16,int(tools.config['price_accuracy'])), select=True, help="If the Tax account is tax code account, this field will contain the taxed amount.If the tax account is base tax code,\
|
||||
this field will contain the basic amount(without tax)."),
|
||||
'invoice': fields.function(_invoice, method=True, string='Invoice',
|
||||
type='many2one', relation='account.invoice', fnct_search=_invoice_search),
|
||||
'account_tax_id':fields.many2one('account.tax', 'Tax'),
|
||||
'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'),
|
||||
#TODO: remove this
|
||||
'amount_taxed':fields.float("Taxed Amount",digits=(16,2)),
|
||||
'amount_taxed':fields.float("Taxed Amount",digits=(16,int(tools.config['price_accuracy']))),
|
||||
|
||||
}
|
||||
|
||||
|
@ -626,6 +626,7 @@ class account_move_line(osv.osv):
|
|||
'debit':debit,
|
||||
'credit':credit,
|
||||
'account_id':writeoff_acc_id,
|
||||
'analytic_account_id': context.get('analytic_id', False),
|
||||
'date':date,
|
||||
'partner_id':partner_id
|
||||
})
|
||||
|
@ -634,7 +635,7 @@ class account_move_line(osv.osv):
|
|||
writeoff_move_id = self.pool.get('account.move').create(cr, uid, {
|
||||
'period_id': writeoff_period_id,
|
||||
'journal_id': writeoff_journal_id,
|
||||
|
||||
'date':date,
|
||||
'state': 'draft',
|
||||
'line_id': writeoff_lines
|
||||
})
|
||||
|
@ -879,7 +880,7 @@ class account_move_line(osv.osv):
|
|||
'amount': vals['debit'] or vals['credit'],
|
||||
'general_account_id': vals['account_id'],
|
||||
'journal_id': journal.analytic_journal_id.id,
|
||||
'ref': vals['ref'],
|
||||
'ref': vals.get('ref', False),
|
||||
})]
|
||||
#else:
|
||||
# raise osv.except_osv(_('No analytic journal !'), _('Please set an analytic journal on this financial journal !'))
|
||||
|
|
|
@ -336,6 +336,7 @@
|
|||
<field name="date"/>
|
||||
<field name="ref"/>
|
||||
<field name="name"/>
|
||||
<field name="account_id"/>
|
||||
<field name="type"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
|
||||
|
@ -346,6 +347,7 @@
|
|||
<form string="Statement lines">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="account_id"/>
|
||||
<field name="type"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field domain="[('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id"/>
|
||||
|
|
|
@ -105,23 +105,41 @@ class account_invoice(osv.osv):
|
|||
cur_obj = self.pool.get('res.currency')
|
||||
for inv in data_inv:
|
||||
debit = credit = 0.0
|
||||
context.update({'date':inv.date_invoice})
|
||||
context_unreconciled=context.copy()
|
||||
for lines in inv.move_lines:
|
||||
if lines.account_id.company_currency_id.id <> inv.currency_id.id:
|
||||
if lines.debit:
|
||||
debit += cur_obj.compute(cr, uid, lines.account_id.company_currency_id.id, inv.currency_id.id, lines.debit)
|
||||
if lines.credit:
|
||||
credit += cur_obj.compute(cr, uid, lines.account_id.company_currency_id.id, inv.currency_id.id, lines.credit)
|
||||
debit_tmp = lines.debit
|
||||
credit_tmp = lines.credit
|
||||
# If currency conversion needed
|
||||
if inv.company_id.currency_id.id <> inv.currency_id.id:
|
||||
# If invoice paid, compute currency amount according to invoice date
|
||||
# otherwise, take the line date
|
||||
if not inv.reconciled:
|
||||
context.update({'date':lines.date})
|
||||
context_unreconciled.update({'date':lines.date})
|
||||
# If amount currency setted, compute for debit and credit in company currency
|
||||
if lines.amount_currency < 0:
|
||||
credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled))
|
||||
elif lines.amount_currency > 0:
|
||||
debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled))
|
||||
# Then, recomput into invoice currency to avoid rounding trouble !
|
||||
debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False,context=context)
|
||||
credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False,context=context)
|
||||
else:
|
||||
debit += lines.debit
|
||||
credit += lines.credit
|
||||
|
||||
debit+=debit_tmp
|
||||
credit+=credit_tmp
|
||||
|
||||
if not inv.amount_total:
|
||||
result = 0.0
|
||||
elif inv.type in ('out_invoice','in_refund'):
|
||||
result = inv.amount_total * (1.0 - credit / (debit + inv.amount_total))
|
||||
amount = credit-debit
|
||||
result = inv.amount_total - amount
|
||||
else:
|
||||
result = inv.amount_total * (1.0 - debit / (credit + inv.amount_total))
|
||||
res[inv.id] = round(result,int(config['price_accuracy']))
|
||||
amount = debit-credit
|
||||
result = inv.amount_total - amount
|
||||
# Use is_zero function to avoid rounding trouble => should be fixed into ORM
|
||||
res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id,result) and result or 0.0
|
||||
|
||||
return res
|
||||
|
||||
def _get_lines(self, cr, uid, ids, name, arg, context=None):
|
||||
|
@ -871,6 +889,16 @@ class account_invoice(osv.osv):
|
|||
date=context['date_p']
|
||||
else:
|
||||
date=time.strftime('%Y-%m-%d')
|
||||
|
||||
# Take the amount in currency and the currency of the payment
|
||||
if 'amount_currency' in context and context['amount_currency'] and 'currency_id' in context and context['currency_id']:
|
||||
amount_currency = context['amount_currency']
|
||||
currency_id = context['currency_id']
|
||||
else:
|
||||
amount_currency = False
|
||||
currency_id = False
|
||||
|
||||
# Pay attention to the sign for both debit/credit AND amount_currency
|
||||
l1 = {
|
||||
'debit': direction * pay_amount>0 and direction * pay_amount,
|
||||
'credit': direction * pay_amount<0 and - direction * pay_amount,
|
||||
|
@ -878,6 +906,8 @@ class account_invoice(osv.osv):
|
|||
'partner_id': invoice.partner_id.id,
|
||||
'ref':invoice.number,
|
||||
'date': date,
|
||||
'currency_id':currency_id,
|
||||
'amount_currency':amount_currency and direction * amount_currency or 0.0,
|
||||
}
|
||||
l2 = {
|
||||
'debit': direction * pay_amount<0 and - direction * pay_amount,
|
||||
|
@ -886,6 +916,8 @@ class account_invoice(osv.osv):
|
|||
'partner_id': invoice.partner_id.id,
|
||||
'ref':invoice.number,
|
||||
'date': date,
|
||||
'currency_id':currency_id,
|
||||
'amount_currency':amount_currency and - direction * amount_currency or 0.0,
|
||||
}
|
||||
|
||||
if not name:
|
||||
|
|
|
@ -24,6 +24,7 @@ import netsvc
|
|||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
pay_form = '''<?xml version="1.0"?>
|
||||
<form string="Pay invoice">
|
||||
|
@ -36,7 +37,7 @@ pay_form = '''<?xml version="1.0"?>
|
|||
</form>'''
|
||||
|
||||
pay_fields = {
|
||||
'amount': {'string': 'Amount paid', 'type':'float', 'required':True},
|
||||
'amount': {'string': 'Amount paid', 'type':'float', 'required':True, 'digits': (16,int(tools.config['price_accuracy']))},
|
||||
'name': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
|
||||
'date': {'string': 'Payment date', 'type':'date', 'required':True, 'default':lambda *args: time.strftime('%Y-%m-%d')},
|
||||
'journal_id': {'string': 'Journal/Payment Mode', 'type': 'many2one', 'relation':'account.journal', 'required':True, 'domain':[('type','=','cash')]},
|
||||
|
@ -52,18 +53,24 @@ def _pay_and_reconcile(self, cr, uid, data, context):
|
|||
pool = pooler.get_pool(cr.dbname)
|
||||
cur_obj = pool.get('res.currency')
|
||||
amount = form['amount']
|
||||
context['analytic_id'] = form.get('analytic_id', False)
|
||||
|
||||
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
||||
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
|
||||
# Compute the amount in company's currency, with the journal currency (which is equal to payment currency)
|
||||
# when it is needed : If payment currency (according to selected journal.currency) is <> from company currency
|
||||
if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
|
||||
ctx = {'date':data['form']['date']}
|
||||
amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
|
||||
|
||||
currency_id = journal.currency.id
|
||||
# Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
|
||||
context.update({'amount_currency':form['amount'],'currency_id':currency_id})
|
||||
|
||||
# Take the choosen date
|
||||
if form.has_key('comment'):
|
||||
context={'date_p':form['date'],'comment':form['comment']}
|
||||
context.update({'date_p':form['date'],'comment':form['comment']})
|
||||
else:
|
||||
context={'date_p':form['date'],'comment':False}
|
||||
context.update({'date_p':form['date'],'comment':False})
|
||||
|
||||
acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
|
||||
if not acc_id:
|
||||
|
@ -77,31 +84,53 @@ def _wo_check(self, cr, uid, data, context):
|
|||
pool = pooler.get_pool(cr.dbname)
|
||||
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
||||
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
|
||||
if invoice.company_id.currency_id.id <> invoice.currency_id.id:
|
||||
return 'addendum'
|
||||
if journal.currency and (journal.currency.id <> invoice.currency_id.id):
|
||||
return 'addendum'
|
||||
if pool.get('res.currency').is_zero(cr, uid, invoice.currency_id,
|
||||
(data['form']['amount'] - invoice.amount_total)):
|
||||
cur_obj = pool.get('res.currency')
|
||||
# Here we need that:
|
||||
# The invoice total amount in company's currency <> paid amount in company currency
|
||||
# (according to the correct day rate, invoicing rate and payment rate are may be different)
|
||||
# => Ask to a write-off of the difference. This could happen even if both amount are equal,
|
||||
# because if the currency rate
|
||||
# Get the amount in company currency for the invoice (according to move lines)
|
||||
inv_amount_company_currency=invoice.move_id.amount
|
||||
# Get the current amount paid in company currency
|
||||
if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
|
||||
ctx = {'date':data['form']['date']}
|
||||
amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['form']['amount'], round=True, context=ctx)
|
||||
else:
|
||||
amount_paid = data['form']['amount']
|
||||
# Get the old payment if there are some
|
||||
if invoice.payment_ids:
|
||||
debit=credit=0.0
|
||||
for payment in invoice.payment_ids:
|
||||
debit+=payment.debit
|
||||
credit+=payment.credit
|
||||
amount_paid+=abs(debit-credit)
|
||||
|
||||
# Test if there is a difference according to currency rouding setting
|
||||
if pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id,
|
||||
(amount_paid - inv_amount_company_currency)):
|
||||
return 'reconcile'
|
||||
return 'addendum'
|
||||
|
||||
_transaction_add_form = '''<?xml version="1.0"?>
|
||||
<form string="Information addendum">
|
||||
<separator string="Write-Off Move" colspan="4"/>
|
||||
<field name="writeoff_acc_id" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
|
||||
<field name="writeoff_journal_id"/>
|
||||
<field name="writeoff_acc_id" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
|
||||
<field name="comment"/>
|
||||
<separator string="Analytic" colspan="4"/>
|
||||
<field name="analytic_id"/>
|
||||
</form>'''
|
||||
|
||||
_transaction_add_fields = {
|
||||
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||
'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
|
||||
'comment': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
|
||||
'comment': {'string': 'Comment', 'type':'char', 'size': 64 , 'required':True},
|
||||
'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
|
||||
}
|
||||
|
||||
def _get_value_addendum(self, cr, uid, data, context={}):
|
||||
return {}
|
||||
return {'comment': _('Write-Off')}
|
||||
|
||||
def _get_period(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
|
|
@ -24,6 +24,8 @@ import netsvc
|
|||
import time
|
||||
import osv
|
||||
import pooler
|
||||
from datetime import datetime
|
||||
from tools.translate import _
|
||||
|
||||
_transaction_form = '''<?xml version="1.0"?>
|
||||
<form string="Reconciliation">
|
||||
|
@ -69,8 +71,18 @@ def _trans_rec_reconcile(self, cr, uid, data, context=None):
|
|||
|
||||
form = data['form']
|
||||
account_id = form.get('writeoff_acc_id', False)
|
||||
period_id = form.get('period_id', False)
|
||||
context['date_p'] = form.get('date_p', False)
|
||||
date = False
|
||||
if context['date_p']:
|
||||
date = datetime.strptime(context['date_p'], '%Y-%m-%d')
|
||||
ids = pool.get('account.period').find(cr, uid, dt=date, context=context)
|
||||
period_id = False
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
|
||||
journal_id = form.get('journal_id', False)
|
||||
context['comment'] = form.get('comment', False)
|
||||
context['analytic_id'] = form.get('analytic_id', False)
|
||||
account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
|
||||
period_id, journal_id, context=context)
|
||||
return {}
|
||||
|
@ -84,23 +96,24 @@ _transaction_add_form = '''<?xml version="1.0"?>
|
|||
<form string="Information addendum">
|
||||
<separator string="Write-Off Move" colspan="4"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="period_id"/>
|
||||
<field name="writeoff_acc_id" domain="[('type', '<>', 'view')]"/>
|
||||
<field name="date_p"/>
|
||||
<field name="comment"/>
|
||||
<separator string="Analytic" colspan="4"/>
|
||||
<field name="analytic_id"/>
|
||||
</form>'''
|
||||
|
||||
_transaction_add_fields = {
|
||||
'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
|
||||
'period_id': {'string': 'Write-Off Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
||||
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||
'date_p': {'string':'Date','type':'date'},
|
||||
'comment': {'string':'Comment','type':'char', 'size': 64, 'required':True},
|
||||
'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
|
||||
}
|
||||
|
||||
def _trans_rec_addendum(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = pool.get('account.period').find(cr, uid, context=context)
|
||||
period_id = False
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
return {'period_id':period_id}
|
||||
date_p = time.strftime('%Y-%m-%d')
|
||||
return {'date_p':date_p, 'comment': _('Write-Off')}
|
||||
|
||||
|
||||
class wiz_reconcile(wizard.interface):
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
import wizard
|
||||
import pooler
|
||||
import netsvc
|
||||
from tools.translate import _
|
||||
|
||||
form = '''<?xml version="1.0"?>
|
||||
<form string="Open Invoice">
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from xml import dom
|
||||
from lxml import etree
|
||||
|
||||
from mx import DateTime
|
||||
from mx.DateTime import now
|
||||
|
@ -163,7 +162,7 @@ class account_analytic_plan_instance(osv.osv):
|
|||
<newline/>"""%(i,tools.to_xml(line.name),tools.to_xml(line.name),line.root_analytic_id and line.root_analytic_id.id or 0)
|
||||
i+=1
|
||||
res['arch'] += "</form>"
|
||||
doc = dom.minidom.parseString(res['arch'].encode('utf8'))
|
||||
doc = etree.fromstring(res['arch'].encode('utf8'))
|
||||
xarch, xfields = self._view_look_dom_arch(cr, uid, doc, view_id, context=context)
|
||||
res['arch'] = xarch
|
||||
res['fields'] = xfields
|
||||
|
|
|
@ -95,6 +95,7 @@ def create_payment(self, cr, uid, data, context):
|
|||
'partner_id': line.partner_id and line.partner_id.id or False,
|
||||
'communication': line.ref or '/',
|
||||
'date': date_to_pay,
|
||||
'currency': line.invoice and line.invoice.currency_id.id or False,
|
||||
}, context=context)
|
||||
return {}
|
||||
|
||||
|
|
|
@ -331,6 +331,16 @@ class product_pricelist_item(osv.osv):
|
|||
'sequence': lambda *a: 5,
|
||||
'price_discount': lambda *a: 0,
|
||||
}
|
||||
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
for obj_list in self.browse(cr, uid, ids):
|
||||
if obj_list.base == -1:
|
||||
main_pricelist = obj_list.price_version_id.pricelist_id.id
|
||||
other_pricelist = obj_list.base_pricelist_id.id
|
||||
if main_pricelist == other_pricelist:
|
||||
return False
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Rule Name', size=64, help="Explicit rule name for this pricelist line."),
|
||||
'price_version_id': fields.many2one('product.pricelist.version', 'Price List Version', required=True, select=True),
|
||||
|
@ -357,6 +367,11 @@ class product_pricelist_item(osv.osv):
|
|||
'price_max_margin': fields.float('Max. Price Margin',
|
||||
digits=(16, int(config['price_accuracy']))),
|
||||
}
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, _('Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList Item!'), ['base_pricelist_id'])
|
||||
]
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product_id, context={}):
|
||||
if not product_id:
|
||||
return {}
|
||||
|
|
Loading…
Reference in New Issue