Skip to content

Commit

Permalink
[MERGE] merged trunk.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vo Minh Thu committed Dec 10, 2012
2 parents ca89ae8 + 590add5 commit 6072fd1
Show file tree
Hide file tree
Showing 346 changed files with 17,877 additions and 5,493 deletions.
2 changes: 1 addition & 1 deletion addons/account/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
'project/analytic_account_demo.xml',
'demo/account_minimal.xml',
'demo/account_invoice_demo.xml',
# 'account_unit_test.xml',
'account_unit_test.xml',
],
'test': [
'test/account_customer_invoice.yml',
Expand Down
19 changes: 10 additions & 9 deletions addons/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def compute(self, cr, uid, id, value, date_ref=False, context=None):
amount = value
result = []
obj_precision = self.pool.get('decimal.precision')
prec = obj_precision.precision_get(cr, uid, 'Account')
for line in pt.line_ids:
prec = obj_precision.precision_get(cr, uid, 'Account')
if line.value == 'fixed':
amt = round(line.value_amount, prec)
elif line.value == 'procent':
Expand All @@ -92,19 +92,20 @@ def compute(self, cr, uid, id, value, date_ref=False, context=None):
next_date += relativedelta(day=line.days2, months=1)
result.append( (next_date.strftime('%Y-%m-%d'), amt) )
amount -= amt
return result

account_payment_term()
amount = reduce(lambda x,y: x+y[1], result, 0.0)
dist = round(value-amount, prec)
if dist:
result.append( (time.strftime('%Y-%m-%d'), dist) )
return result

class account_payment_term_line(osv.osv):
_name = "account.payment.term.line"
_description = "Payment Term Line"
_columns = {
'name': fields.char('Line Name', size=32, required=True),
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the payment term lines from the lowest sequences to the higher ones"),
'value': fields.selection([('procent', 'Percent'),
('balance', 'Balance'),
('fixed', 'Fixed Amount')], 'Valuation',
('fixed', 'Fixed Amount')], 'Computation',
required=True, help="""Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be treated."""),

'value_amount': fields.float('Amount To Pay', digits_compute=dp.get_precision('Payment Term'), help="For percent enter a ratio between 0-1."),
Expand All @@ -115,10 +116,10 @@ class account_payment_term_line(osv.osv):
}
_defaults = {
'value': 'balance',
'sequence': 5,
'days': 30,
'days2': 0,
}
_order = "sequence"
_order = "value desc,days"

def _check_percent(self, cr, uid, ids, context=None):
obj = self.browse(cr, uid, ids[0], context=context)
Expand Down Expand Up @@ -1082,7 +1083,7 @@ def _icon_get(self, cr, uid, ids, field_name, arg=None, context=None):
'journal_id': fields.many2one('account.journal', 'Journal', required=True, ondelete="cascade"),
'period_id': fields.many2one('account.period', 'Period', required=True, ondelete="cascade"),
'icon': fields.function(_icon_get, string='Icon', type='char', size=32),
'active': fields.boolean('Active', required=True, help="If the active field is set to False, it will allow you to hide the journal period without removing it."),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the journal period without removing it."),
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True,
help='When journal period is created. The status is \'Draft\'. If a report is printed it comes to \'Printed\' status. When all transactions are done, it comes in \'Done\' status.'),
'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'),
Expand Down
12 changes: 8 additions & 4 deletions addons/account/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ def _get_type(self, cr, uid, context=None):

def _reconciled(self, cr, uid, ids, name, args, context=None):
res = {}
for id in ids:
res[id] = self.test_paid(cr, uid, [id])
wf_service = netsvc.LocalService("workflow")
for inv in self.browse(cr, uid, ids, context=context):
res[inv.id] = self.test_paid(cr, uid, [inv.id])
if not res[inv.id] and inv.state == 'paid':
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'open_test', cr)
return res

def _get_reference_type(self, cr, uid, context=None):
Expand Down Expand Up @@ -1159,7 +1162,7 @@ def _refund_cleanup_lines(self, cr, uid, lines):
return map(lambda x: (0,0,x), lines)

def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id', 'company_id'])
invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id', 'company_id', 'user_id', 'fiscal_position'])
obj_invoice_line = self.pool.get('account.invoice.line')
obj_invoice_tax = self.pool.get('account.invoice.tax')
obj_journal = self.pool.get('account.journal')
Expand Down Expand Up @@ -1208,7 +1211,8 @@ def refund(self, cr, uid, ids, date=None, period_id=None, description=None, jour
})
# take the id part of the tuple returned for many2one fields
for field in ('partner_id', 'company_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'):
'account_id', 'currency_id', 'payment_term', 'journal_id',
'user_id', 'fiscal_position'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
new_ids.append(self.create(cr, uid, invoice))
Expand Down
13 changes: 9 additions & 4 deletions addons/account/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ def _get_reconcile(self, cr, uid, ids,name, unknow_none, context=None):
'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),
'reconcile': fields.function(_get_reconcile, type='char', string='Reconcile'),
'reconcile': fields.function(_get_reconcile, type='char', string='Reconcile Ref'),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')),
'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."),
'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount in Currency', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."),
'amount_residual': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
'journal_id': fields.related('move_id', 'journal_id', string='Journal', type='many2one', relation='account.journal', required=True, select=True,
Expand All @@ -456,7 +456,7 @@ def _get_reconcile(self, cr, uid, ids,name, unknow_none, context=None):
store = {
'account.move': (_get_move_lines, ['period_id'], 20)
}),
'blocked': fields.boolean('Litigation', help="You can check this box to mark this journal item as a litigation with the associated partner"),
'blocked': fields.boolean('No Follow-up', help="You can check this box to mark this journal item as a litigation with the associated partner"),
'partner_id': fields.many2one('res.partner', 'Partner', select=1, ondelete='restrict'),
'date_maturity': fields.date('Due date', select=True ,help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."),
'date': fields.related('move_id','date', string='Effective date', type='date', required=True, select=True,
Expand Down Expand Up @@ -856,7 +856,12 @@ def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_p
if r[0][1] != None:
raise osv.except_osv(_('Error!'), _('Some entries are already reconciled.'))

if (not currency_obj.is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \
if context.get('fy_closing'):
# We don't want to generate any write-off when being called from the
# wizard used to close a fiscal year (and it doesn't give us any
# writeoff_acc_id).
pass
elif (not currency_obj.is_zero(cr, uid, account.company_id.currency_id, writeoff)) or \
(account.currency_id and (not currency_obj.is_zero(cr, uid, account.currency_id, currency))):
if not writeoff_acc_id:
raise osv.except_osv(_('Warning!'), _('You have to provide an account for the write off/exchange difference entry.'))
Expand Down
35 changes: 8 additions & 27 deletions addons/account/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1549,10 +1549,8 @@
<field name="model">account.payment.term.line</field>
<field name="arch" type="xml">
<tree string="Payment Term">
<field name="sequence"/>
<field name="name"/>
<field name="value"/>
<field name="value_amount"/>
<field name="value_amount" attrs="{'readonly':[('value','=','balance')]}"/>
<field name="days"/>
<field name="days2"/>
</tree>
Expand All @@ -1563,37 +1561,20 @@
<field name="model">account.payment.term.line</field>
<field name="arch" type="xml">
<form string="Payment Term" version="7.0">
<group>
<field name="name"/>
<field name="sequence"/>
</group>
<group>
<group string="Amount Computation">
<field name="value"/>
<field name="value_amount" attrs="{'readonly':[('value','=','balance')]}"/>
<field name="value"/>
<label for="value_amount" string="Amount To Pay" attrs="{'invisible':[('value','=','balance')]}"/>
<div attrs="{'invisible':[('value','=','balance')]}">
<field name="value_amount" class="oe_inline"/>
<label string="%%" class="oe_inline" attrs="{'invisible':['!',('value','=','procent')]}" />
</div>
</group>
<group string="Due Date Computation">
<field name="days"/>
<field name="days2"/>
</group>
</group>

<separator string="Example"/>
<label string="At 14 net days 2 percent, remaining amount at 30 days end of month."/>
<group>
<label string="Line 1:" colspan="2"/>
<label string=" Valuation: Percent"/>
<label string=" Number of Days: 14"/>
<label string=" Value amount: 0.02"/>
<label string=" Day of the Month: 0"/>
</group>
<group>
<label string="Line 2:" colspan="2"/>
<label string=" Valuation: Balance"/>
<label string=" Number of Days: 30"/>
<label string=" Value amount: n.a"/>
<label string=" Day of the Month= -1"/>
</group>
</form>
</field>
</record>
Expand All @@ -1616,7 +1597,7 @@
<field name="name"/>
<field name="active"/>
</group>
<field name="note" placeholder="Note for the invoice..."/>
<field name="note" placeholder="Payment term explanation for the customer..."/>
<separator string="Computation"/>
<field name="line_ids"/>
</form>
Expand Down
56 changes: 26 additions & 30 deletions addons/account/data/account_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,33 @@
<!--
Payment term
-->
<record id="account_payment_term" model="account.payment.term">
<field name="name">30 Days End of Month</field>
<field name="note">30 Days End of Month</field>
<record id="account_payment_term_immediate" model="account.payment.term">
<field name="name">Immediate Payment</field>
<field name="note">Immediate Payment</field>
</record>
<record id="account_payment_term_line" model="account.payment.term.line">
<field name="name">30 Days End of Month</field>

<record id="account_payment_term_line_immediate" model="account.payment.term.line">
<field name="name">Immediate Payment</field>
<field name="value">balance</field>
<field eval="30" name="days"/>
<field eval="-1" name="days2"/>
<field eval="account_payment_term" name="payment_id"/>
<field eval="0" name="days"/>
<field eval="0" name="days2"/>
<field eval="account_payment_term_immediate" name="payment_id"/>
</record>


<record id="account_payment_term_15days" model="account.payment.term">
<field name="name">15 Days</field>
<field name="note">15 Days</field>
</record>

<record id="account_payment_term_line_15days" model="account.payment.term.line">
<field name="name">15 Days</field>
<field name="value">balance</field>
<field eval="15" name="days"/>
<field eval="0" name="days2"/>
<field eval="account_payment_term_15days" name="payment_id"/>
</record>

<record forcecreate="True" id="decimal_payment" model="decimal.precision">
<field name="name">Payment Term</field>
<field name="digits">6</field>
Expand All @@ -30,35 +46,15 @@
<field name="name">30 Net Days</field>
<field name="note">30 Net Days</field>
</record>

<record id="account_payment_term_line_net" model="account.payment.term.line">
<field name="name">30 Net Days</field>
<field name="value">balance</field>
<field eval="30" name="days"/>
<field eval="0" name="days2"/>
<field eval="account_payment_term_net" name="payment_id"/>
</record>

<record id="account_payment_term_advance" model="account.payment.term">
<field name="name">30% Advance End 30 Days</field>
<field name="note">30% Advance End 30 Days</field>
</record>
<record id="account_payment_term_line_advance1" model="account.payment.term.line">
<field name="name">30% Advance</field>
<field name="value">procent</field>
<field eval="3" name="sequence"/>
<field eval="0.300000" name="value_amount"/>
<field eval="0" name="days"/>
<field eval="0" name="days2"/>
<field eval="account_payment_term_advance" name="payment_id"/>
</record>
<record id="account_payment_term_line_advance2" model="account.payment.term.line">
<field name="name">Remaining Balance</field>
<field name="value">balance</field>
<field eval="30" name="days"/>
<field eval="-1" name="days2"/>
<field eval="account_payment_term_advance" name="payment_id"/>
</record>


<!--
Account Journal Sequences
-->
Expand Down
35 changes: 35 additions & 0 deletions addons/account/demo/account_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,41 @@
<field eval="time.strftime('%Y')+'-12-31'" name="date_stop"/>
<field name="company_id" ref="base.main_company"/>
</record>

<!-- Payment Term -->

<record id="account_payment_term" model="account.payment.term">
<field name="name">30 Days End of Month</field>
<field name="note">30 Days End of Month</field>
</record>
<record id="account_payment_term_line" model="account.payment.term.line">
<field name="name">30 Days End of Month</field>
<field name="value">balance</field>
<field eval="30" name="days"/>
<field eval="-1" name="days2"/>
<field eval="account_payment_term" name="payment_id"/>
</record>

<record id="account_payment_term_advance" model="account.payment.term">
<field name="name">30% Advance End 30 Days</field>
<field name="note">30% Advance End 30 Days</field>
</record>
<record id="account_payment_term_line_advance1" model="account.payment.term.line">
<field name="name">30% Advance</field>
<field name="value">procent</field>
<field eval="3" name="sequence"/>
<field eval="0.300000" name="value_amount"/>
<field eval="0" name="days"/>
<field eval="0" name="days2"/>
<field eval="account_payment_term_advance" name="payment_id"/>
</record>
<record id="account_payment_term_line_advance2" model="account.payment.term.line">
<field name="name">Remaining Balance</field>
<field name="value">balance</field>
<field eval="30" name="days"/>
<field eval="-1" name="days2"/>
<field eval="account_payment_term_advance" name="payment_id"/>
</record>

<record id="base.user_demo" model="res.users">
<field name="groups_id" eval="[(4,ref('account.group_account_user'))]"/>
Expand Down
Loading

0 comments on commit 6072fd1

Please sign in to comment.