[IMP] account, usability: improved account.move form view

* proposal of the next line debit/credit
* name of account.move.line isn't required anymore, but reference of account.move is
This commit is contained in:
qdp-odoo
2017-02-28 12:47:25 +01:00
parent 1162304a1a
commit 054906a94a
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -369,7 +369,7 @@ class AccountMoveLine(models.Model):
counterpart = list(counterpart)[0:2] + ["..."]
self.counterpart = ",".join(counterpart)
name = fields.Char(required=True, string="Label")
name = fields.Char(string="Label")
quantity = fields.Float(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 useful for some reports.")
product_uom_id = fields.Many2one('product.uom', string='Unit of Measure')
@@ -434,6 +434,23 @@ class AccountMoveLine(models.Model):
('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'),
]
@api.model
def default_get(self, fields):
rec = super(AccountMoveLine, self).default_get(fields)
if 'line_ids' not in self._context:
return rec
#compute the default credit/debit of the next line in case of a manual entry
balance = 0
for line in self._context['line_ids']:
if line[2]:
balance += line[2]['debit'] - line[2]['credit']
if balance < 0:
rec.update({'debit': -balance})
if balance > 0:
rec.update({'credit': balance})
return rec
@api.multi
@api.constrains('currency_id', 'account_id')
def _check_currency(self):
+1 -1
View File
@@ -1299,7 +1299,7 @@
<field name="date"/>
</group>
<group>
<field name="ref"/>
<field name="ref" required="1"/>
<field name="company_id" required="1" groups="base.group_multi_company"/>
<field name="amount" invisible="1"/>
<field name="currency_id" invisible="1"/>