trytonpsk-sale_pos_frontend.../production.py
2021-07-22 17:35:39 -05:00

84 lines
2.7 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
# from trytond.pyson import Eval
# from trytond.model import fields
from trytond.transaction import Transaction
from decimal import Decimal
from trytond.pool import PoolMeta, Pool
def round_dec(number):
return Decimal(number.quantize(Decimal('.01')))
class Production(metaclass=PoolMeta):
__name__ = 'production'
@classmethod
def __setup__(cls):
super(Production, cls).__setup__()
def create_account_move_stock(self, kind):
if kind == 'assigned':
return
pool = Pool()
Move = pool.get('account.move')
Line = pool.get('account.move.line')
Period = pool.get('account.period')
Journal = pool.get('account.journal')
Period = pool.get('account.period')
company_id = Transaction().context.get('company')
company = pool.get('company.company')(company_id)
company_party = company.party
journals = Journal.search([
('code', '=', 'STO')
])
if journals:
journal = journals[0]
if not self.planned_date:
self.raise_user_error('planned_date_required')
lines = []
balance = Decimal(0)
# FIXME
# for _in in self.inputs:
# if _in.product.cost_price == 0:
# continue
# account_id = _in.product.template.account_category.account_stock.id
# credit = round_dec(_in.product.cost_price * Decimal(_in.quantity))
# # credit = round(credit, 0)
#
# lines.append({
# 'description': _in.product.template.name,
# 'party': company_party.id,
# 'account': account_id,
# 'debit': Decimal("0.00"),
# 'credit': credit
# })
#
# balance += credit
#
# account_stock_id = self.product.template.account_category.account_stock.id
# lines.append({
# 'description': self.product.template.name,
# 'account': account_stock_id,
# 'party': company_party.id,
# 'debit': balance,
# 'credit': Decimal("0.00")
# })
#
# period_id = Period.find(self.company.id, date=self.planned_date)
# move, = Move.create([{
# 'journal': journal.id,
# 'period': period_id,
# 'date': self.planned_date,
# 'state': 'draft',
# 'lines': [('create', lines)],
# 'origin': str(self),
# }])
# Move.post([move])
#
# field = 'production_finished_move'
# self.write([self], {field: move})