Rationalize accounting moves and lines
issue2056 review503006
This commit is contained in:
@@ -13,6 +13,7 @@ def register():
|
||||
Category,
|
||||
Template,
|
||||
Configuration,
|
||||
AccountMove,
|
||||
UpdateCostPriceAsk,
|
||||
UpdateCostPriceShowMove,
|
||||
module='account_stock_continental', type_='model')
|
||||
|
||||
+10
-1
@@ -4,7 +4,7 @@ from trytond.model import fields
|
||||
from trytond.pyson import Eval, Bool, Get
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
__all__ = ['Configuration']
|
||||
__all__ = ['Configuration', 'AccountMove']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
@@ -19,3 +19,12 @@ class Configuration:
|
||||
'account.account', 'Cost Price Counterpart Account', domain=[
|
||||
('company', 'in', [Get(Eval('context', {}), 'company'), None]),
|
||||
]))
|
||||
|
||||
|
||||
class AccountMove:
|
||||
__name__ = 'account.move'
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return super(AccountMove, cls)._get_origin() + ['stock.move',
|
||||
'product.product']
|
||||
|
||||
+10
@@ -73,5 +73,15 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="kind">stock</field>
|
||||
</record>
|
||||
|
||||
<!-- Read access for origin field on account.move -->
|
||||
<record model="ir.model.access" id="access_move_group_account">
|
||||
<field name="model" search="[('model', '=', 'stock.move')]"/>
|
||||
<field name="group" ref="account.group_account"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_delete" eval="False"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
+3
-4
@@ -173,7 +173,7 @@ class UpdateCostPriceShowMove(ModelView):
|
||||
('id', '!=', Eval('stock_account')),
|
||||
],
|
||||
depends=['company', 'stock_account'], required=True)
|
||||
description = fields.Char('Description', required=True)
|
||||
description = fields.Char('Description')
|
||||
|
||||
|
||||
class UpdateCostPrice(Wizard):
|
||||
@@ -260,13 +260,11 @@ class UpdateCostPrice(Wizard):
|
||||
Line = Pool.get('account.move.line')
|
||||
amount = self.show_move.amount
|
||||
return [Line(
|
||||
name=self.ask_price.product.name,
|
||||
debit=amount if amount > 0 else 0,
|
||||
credit=-amount if amount < 0 else 0,
|
||||
account=self.show_move.stock_account,
|
||||
),
|
||||
Line(
|
||||
name=self.ask_price.product.name,
|
||||
debit=-amount if amount < 0 else 0,
|
||||
credit=amount if amount > 0 else 0,
|
||||
account=self.show_move.counterpart,
|
||||
@@ -284,10 +282,11 @@ class UpdateCostPrice(Wizard):
|
||||
period_id = Period.find(user.company.id)
|
||||
with Transaction().set_user(0, set_context=True):
|
||||
return Move(
|
||||
name=self.show_move.description,
|
||||
description=self.show_move.description,
|
||||
period=period_id,
|
||||
journal=self.show_move.journal,
|
||||
date=Date.today(),
|
||||
origin=self.ask_price.product,
|
||||
lines=self.get_move_lines(),
|
||||
)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Move:
|
||||
'wrong type'
|
||||
|
||||
with Transaction().set_user(0, set_context=True):
|
||||
move_line = AccountMoveLine(name=self.rec_name)
|
||||
move_line = AccountMoveLine()
|
||||
if (type_.endswith('supplier')
|
||||
and self.product.cost_price_method != 'fixed'):
|
||||
unit_price = self.unit_price
|
||||
@@ -58,7 +58,6 @@ class Move:
|
||||
AccountMoveLine = pool.get('account.move.line')
|
||||
with Transaction().set_user(0, set_context=True):
|
||||
move_line = AccountMoveLine(
|
||||
name=self.rec_name,
|
||||
account=self.product.account_stock_used,
|
||||
)
|
||||
if not amount:
|
||||
@@ -89,6 +88,7 @@ class Move:
|
||||
journal=account_configuration.stock_journal,
|
||||
period=period_id,
|
||||
date=date,
|
||||
origin=self,
|
||||
lines=move_lines,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user