Initial import from Docker volume

This commit is contained in:
root
2025-12-26 13:11:43 +00:00
commit 4998dc066a
13336 changed files with 1767801 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# 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.pool import Pool
from . import account, invoice, product, stock
def register():
Pool.register(
product.Category,
product.CategoryAccount,
product.Template,
product.Product,
stock.Move,
invoice.InvoiceLine,
account.FiscalYear,
module='account_stock_anglo_saxon', type_='model')

View File

@@ -0,0 +1,13 @@
# 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.pool import PoolMeta
class FiscalYear(metaclass=PoolMeta):
__name__ = 'account.fiscalyear'
@classmethod
def __setup__(cls):
super(FiscalYear, cls).__setup__()
cls.account_stock_method.selection.append(
('anglo_saxon', 'Anglo-Saxon'))

View File

@@ -0,0 +1,8 @@
# 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.exceptions import UserWarning
class COGSWarning(UserWarning):
pass

View File

@@ -0,0 +1,180 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import operator
from decimal import Decimal
from trytond.i18n import gettext
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from .exceptions import COGSWarning
import logging
logger = logging.getLogger(__name__)
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
def _get_anglo_saxon_move_lines(self, amount, type_):
'''
Return account move for anglo-saxon stock accounting
'''
pool = Pool()
MoveLine = pool.get('account.move.line')
Currency = pool.get('currency.currency')
Date = Pool().get('ir.date')
AccountConfiguration = Pool().get('account.configuration')
account_configuration = AccountConfiguration(1)
assert type_.startswith('in_') or type_.startswith('out_'), \
'wrong type'
result = []
move_line = MoveLine()
move_line.description = self.description
move_line.amount_second_currency = None
move_line.second_currency = None
move_line.lot = self.lot
amount_converted = amount
if self.invoice.currency != self.invoice.company.currency and type_ == 'in_supplier':
if account_configuration.stock_fx_forex == 'forex':
frate,amt = move_line.lot.get_forex_rate(amount)
logger.info("GET_PARTY_LINE:%s",frate)
if frate > 0:
amount = round(frate * amount,2)
logger.info("GET_PARTY_LINE2:%s",amount)
with Transaction().set_context(date=Date.today()):
amount += Currency.compute(self.invoice.currency,
amt, self.invoice.company.currency)
logger.info("GET_PARTY_LINE3:%s",amount)
amount_converted = round(amount,2)
else:
if self.invoice.rate:
amount_converted = round(amount / self.invoice.rate,2)
else:
with Transaction().set_context(date=self.invoice.currency_date):
amount_converted = Currency.compute(self.invoice.currency,
amount, self.invoice.company.currency)
else:
if self.invoice.rate:
amount_converted = round(amount / self.invoice.rate,2)
else:
with Transaction().set_context(date=self.invoice.currency_date):
amount_converted = Currency.compute(self.invoice.currency,
amount, self.invoice.company.currency)
move_line.second_currency = self.invoice.currency
if amount_converted < 0:
if type_.startswith('in_'):
move_line.debit = Decimal(0)
move_line.credit = -amount_converted
move_line.account = self.product.account_stock_in_used
if move_line.second_currency:
move_line.amount_second_currency = amount
else:
move_line.debit = Decimal(0)
move_line.credit = -amount_converted
move_line.account = self.product.account_stock_out_used
if move_line.second_currency:
move_line.amount_second_currency = amount
else:
if type_.startswith('in_'):
move_line.debit = amount_converted
move_line.credit = Decimal(0)
move_line.account = self.product.account_stock_in_used
if move_line.second_currency:
move_line.amount_second_currency = amount
else:
move_line.debit = Decimal(0)
move_line.credit = amount_converted
move_line.account = self.product.account_stock_out_used
if move_line.second_currency:
move_line.amount_second_currency = -amount
logger.info("_GET_ANGLO_MOVE_LINE_ACCOUNT1:%s",move_line.account)
result.append(move_line)
debit, credit = move_line.debit, move_line.credit
move_line = MoveLine()
move_line.lot = self.lot
move_line.description = self.description
#move_line.amount_second_currency = move_line.second_currency = None
move_line.debit, move_line.credit = credit, debit
if type_.endswith('supplier'):
move_line.account = self.account
else:
move_line.account = self.product.account_cogs_used
logger.info("_GET_ANGLO_MOVE_LINE_ACCOUNT2:%s",move_line.account)
if move_line.account.party_required:
move_line.party = self.invoice.party
result.append(move_line)
return result
def get_move_lines(self):
pool = Pool()
Move = pool.get('stock.move')
Period = pool.get('account.period')
Warning = pool.get('res.user.warning')
logger.info("ENTERING_ANGLO_SAXON_GET_MOVE_LINES:%s",self)
result = super(InvoiceLine, self).get_move_lines()
if self.type != 'line':
return result
if not self.product:
return result
if self.product.type != 'goods' and not self.product.landed_cost:
return result
accounting_date = (self.invoice.accounting_date
or self.invoice.invoice_date)
period = Period.find(self.invoice.company, date=accounting_date)
if period.fiscalyear.account_stock_method != 'anglo_saxon':
return result
# an empty list means we'll use the current cost price
moves = []
for move in self.stock_moves:
if move.state != 'done':
continue
# remove move for different product
if move.product != self.product:
warning_name = '%s.stock.different_product' % self
if Warning.check(warning_name):
raise COGSWarning(warning_name,
gettext('account_stock_anglo_saxon'
'.msg_invoice_line_stock_move_different_product',
line=self.rec_name,
product=self.product.rec_name))
else:
moves.append(move)
if self.invoice.type == 'in':
type_ = 'in_supplier'
elif self.invoice.type == 'out':
type_ = 'out_customer'
# if self.quantity < 0:
# direction, target = type_.split('_')
# if direction == 'in':
# direction = 'out'
# else:
# direction = 'in'
# type_ = '%s_%s' % (direction, target)
# moves.sort(key=operator.attrgetter('effective_date'))
# cost = Move.update_anglo_saxon_quantity_product_cost(
# self.product, moves, abs(self.quantity), self.unit, type_)
# cost = self.invoice.company.currency.round(cost)
if type_ == 'in_supplier':
cost = self.amount
else:
cost = self.lot.get_cog()
logger.info("GETMOVELINES_COST:%s",cost)
with Transaction().set_context(
company=self.invoice.company.id, date=accounting_date):
anglo_saxon_move_lines = self._get_anglo_saxon_move_lines(
cost, type_)
result.extend(anglo_saxon_move_lines)
return result

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Compte cost béns venuts"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Compte cost béns venuts"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Quantitat anglosaxona d'entrada"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Quantitat anglosaxona de sortida"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"La línia de factura '%(line)s' està vinculada amb moviments d'existències de productes diferents de '%(product)s'.\n"
"Això pot comportar un càlcul erroni del COGS."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "La quantitat anglo-saxona no pot ser major que la quantitat."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Anglosaxó"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Konto Kosten der verkauften Waren"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Konto Kosten der verkauften Waren"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Eingang (Angelsächsische Bewertung)"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Ausgang (Angelsächsische Bewertung)"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"Die Rechnungsposition '%(line)s' steht in Beziehung zu Warenbewegungen für andere Artikel als \"%(product)s\".\n"
"Dies kann zu einer falschen Berechnung der Kosten der verkauften Waren (COGS) führen."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "Anzahl (Angelsächsische Bewertung) kann nicht größer als Anzahl sein."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Angelsächsisch"

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Cuenta coste de bienes vendidos"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Cuenta coste de bienes vendidos"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Cantidad anglosajona de entrada"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Cantidad anglosajona de salida"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"La linea de factura '%(line)s' esta vinculada con movimientos de existencias de productos distintos de '%(product)s'. \n"
"Esto puede generar un cálculo del COGS erróneo."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "La cantidad anglosajona no puede ser mayor que la cantidad."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Anglosajón"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Cuenta de costo de mercancías vendidas"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Cuenta de costo de mercancías vendidas"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Omahinna konto"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Omahinna konto"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Sisesta Anglo-Saxon kogus"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Väljasta Anglo-Saxon kogus"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"Arve rida \"%(line)s\" on seotud tootest \"%(product)s\" erineva laoliikumise reaga.\n"
"See võib arvutada vale toote omahinna."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "Aglo-Saxson kogus ei või olla suurem kogusest."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Anglo-Saxon"

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "حساب هزینه از فروش کالا ها"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "حساب هزینه از فروش کالا ها"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "مقدار ورودی آنگلو-ساکسون"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "مقدار خروجی آنگلو-ساکسون"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"سطر صورتحساب : \"%s'\" مرتبط است با جابجایی موجودی محصولات دیگر از: \"%s'\".\n"
"این ممکن است COGS اشتباه را محاسبه کند."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "کمیت آنگلو-ساکسون نمی تواند بیشتر از مقدار باشد."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "آنگلو-ساکسون"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,36 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Compte « coût des marchandises vendues »"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Compte « coût des marchandises vendues »"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Quantité anglo-saxonne entrée"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Quantité anglo-saxonne sortie"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"La ligne de facture « %(line)s » est liée à des mouvements de stock pour d'autres produits que « %(product)s ».\n"
"Ça pourrait calculer un coût des marchandises vendues faux."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
"La quantité anglo-saxonne ne peut pas être plus grande que la quantité."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Anglo-Saxonne"

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "ELÁBÉ számla"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "ELÁBÉ számla"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"A „%(line)s” számlasorhoz nem a „%(product)s” termékhez kapcsolódó készletmozgások tartoznak.\n"
"Ez rossz ELÁBÉ számításához vezethet."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "angolszász"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,36 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Conto costo del venduto"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Conto costo del venduto"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Input quantità - angolsassone"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "output quantità - angolsassone"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"La riga della fattura \"%(line)s\" è collegata a movimenti di stock di prodotti diversi da \"%(product)s\".\n"
"Questo potrebbe calcolare un COGS errato."
#, fuzzy
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "La quantità anglo-sassone non può essere maggiore della quantità."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "angolsassone"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,35 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "rekening « kosten van verkochte goederen »"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "rekening « kosten van verkochte goederen »"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "ingave Angelsaksische hoeveelheid"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Output Angelsaksische hoeveelheid"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"De factuurlijn \"%(line)s\" is gekoppeld aan voorraadbewegingen van andere producten dan \"%(product)s\".\n"
"Dit kan een verkeerde COGS berekenen.(cogs=kost verkochte goederen)."
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "Angelsaksische hoeveelheid kan niet groter zijn dan hoeveelheid."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Angelsaksisch"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,37 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Conta de Custo de Mercadorias Vendidas"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Conta de Custo de Mercadorias Vendidas"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Quantidade Anglo-Saxã de Entrada"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Quantidade Anglo-Saxã de Saída"
#, fuzzy
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
"A linha da fatura '%(line)s' está vinculada a movimentações de estoque de outros produtos que não '%(product)s'.\n"
"Isso pode computar um COGS errado."
#, fuzzy
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "A quantidade anglo-saxã não pode ser maior do que a quantidade."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Anglo-Saxão"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,34 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Konto stroškov prodanega blaga"
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr "Konto stroškov prodanega blaga"
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr "Vhodna anglosaška količina"
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr "Izhodna anglosaška količina"
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
#, fuzzy
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr "Anglosaška količina ne more biti večja od same količine."
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr "Anglosaški"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.category,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:product.category.account,account_cogs:"
msgid "Account Cost of Goods Sold"
msgstr ""
msgctxt "field:stock.move,in_anglo_saxon_quantity:"
msgid "Input Anglo-Saxon Quantity"
msgstr ""
msgctxt "field:stock.move,out_anglo_saxon_quantity:"
msgid "Output Anglo-Saxon Quantity"
msgstr ""
msgctxt "model:ir.message,text:msg_invoice_line_stock_move_different_product"
msgid ""
"The invoice line \"%(line)s\" is linked to stock moves of other products than \"%(product)s\".\n"
"This may compute a wrong COGS."
msgstr ""
msgctxt "model:ir.message,text:msg_move_quantity_greater"
msgid "Anglo-Saxon quantity cannot be greater than quantity."
msgstr ""
msgctxt "selection:account.fiscalyear,account_stock_method:"
msgid "Anglo-Saxon"
msgstr ""

View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data grouped="1">
<record model="ir.message" id="msg_invoice_line_stock_move_different_product">
<field name="text">The invoice line "%(line)s" is linked to stock moves of other products than "%(product)s".
This may compute a wrong COGS.</field>
</record>
<record model="ir.message" id="msg_move_quantity_greater">
<field name="text">Anglo-Saxon quantity cannot be greater than quantity.</field>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="bg">
<record id="account_template_cogs_bg" model="account.account.template">
<field name="name">COGS</field>
<field name="type" ref="account.account_type_template_expense_bg"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_bg"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="ca">
<record id="account_template_cogs_ca" model="account.account.template">
<field name="name">COGS</field>
<field name="type" ref="account.account_type_template_expense_ca"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_ca"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="de">
<record id="account_template_cogs_de" model="account.account.template">
<field name="name">Kosten der verkauften Waren (COGS)</field>
<field name="type" ref="account.account_type_template_expense_de"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_de"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="en">
<record id="account_template_cogs_en" model="account.account.template">
<field name="name">COGS</field>
<field name="type" ref="account.account_type_template_expense_en"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_en"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="es">
<record id="account_template_cogs_es" model="account.account.template">
<field name="name">CMV</field>
<field name="type" ref="account.account_type_template_expense_es"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_es"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="fr">
<record id="account_template_cogs_fr" model="account.account.template">
<field name="name">Prix du bien vendu</field>
<field name="type" ref="account.account_type_template_expense_fr"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_fr"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="nl">
<record id="account_template_cogs_nl" model="account.account.template">
<field name="name">COGS</field>
<field name="type" ref="account.account_type_template_expense_nl"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_nl"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="pt">
<record id="account_template_cogs_pt" model="account.account.template">
<field name="name">Custo das Mercadorias Vendidas (CMV)</field>
<field name="type" ref="account.account_type_template_expense_pt"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_pt"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="ru">
<record id="account_template_cogs_ru" model="account.account.template">
<field name="name">COGS</field>
<field name="type" ref="account.account_type_template_expense_ru"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_ru"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data language="sl">
<record id="account_template_cogs_sl" model="account.account.template">
<field name="name">COGS</field>
<field name="type" ref="account.account_type_template_expense_sl"/>
<field name="reconcile" eval="True"/>
<field name="parent" ref="account.account_template_root_sl"/>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,69 @@
# 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.model import fields
from trytond.modules.account_product.product import (
account_used, template_property)
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
class Category(metaclass=PoolMeta):
__name__ = 'product.category'
account_cogs = fields.MultiValue(fields.Many2One('account.account',
'Account Cost of Goods Sold', domain=[
('closed', '!=', True),
('type.expense', '=', True),
('company', '=', Eval('context', {}).get('company', -1)),
],
states={
'invisible': (~Eval('context', {}, ).get('company')
| Eval('account_parent')
| ~Eval('accounting', False)),
}))
@classmethod
def multivalue_model(cls, field):
pool = Pool()
if field == 'account_cogs':
return pool.get('product.category.account')
return super(Category, cls).multivalue_model(field)
@property
@account_used('account_cogs')
def account_cogs_used(self):
pass
@fields.depends('accounting', 'account_cogs')
def on_change_accounting(self):
super().on_change_accounting()
if not self.accounting:
self.account_cogs = None
class CategoryAccount(metaclass=PoolMeta):
__name__ = 'product.category.account'
account_cogs = fields.Many2One(
'account.account', "Account Cost of Goods Sold",
domain=[
('closed', '!=', True),
('type.expense', '=', True),
('company', '=', Eval('company', -1)),
])
@classmethod
def get_account_stock_type_statements(cls):
return super().get_account_stock_type_statements() + ['balance']
class Template(metaclass=PoolMeta):
__name__ = 'product.template'
@property
@account_used('account_cogs', 'account_category')
def account_cogs_used(self):
pass
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
account_cogs_used = template_property('account_cogs_used')

View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="category_view_form">
<field name="model">product.category</field>
<field name="inherit" ref="product.category_view_form"/>
<field name="name">category_form</field>
</record>
</data>
</tryton>

View File

@@ -0,0 +1,183 @@
# 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 decimal import Decimal
from trytond.model import Check, fields
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
import logging
logger = logging.getLogger(__name__)
def _get_field(type_):
if type_.startswith('in_'):
return 'in_anglo_saxon_quantity'
else:
return 'out_anglo_saxon_quantity'
class Move(metaclass=PoolMeta):
__name__ = 'stock.move'
in_anglo_saxon_quantity = fields.Float('Input Anglo-Saxon Quantity',
required=True)
out_anglo_saxon_quantity = fields.Float('Output Anglo-Saxon Quantity',
required=True)
@classmethod
def __setup__(cls):
super(Move, cls).__setup__()
cls._allow_modify_closed_period.update(['in_anglo_saxon_quantity',
'out_anglo_saxon_quantity'])
t = cls.__table__()
cls._sql_constraints += [
('check_in_anglo_saxon_quantity',
Check(t, t.quantity >= t.in_anglo_saxon_quantity),
'account_stock_anglo_saxon.msg_move_quantity_greater'),
('check_out_anglo_saxon_quantity',
Check(t, t.quantity >= t.out_anglo_saxon_quantity),
'account_stock_anglo_saxon.msg_move_quantity_greater'),
]
@staticmethod
def default_in_anglo_saxon_quantity():
return 0.0
@staticmethod
def default_out_anglo_saxon_quantity():
return 0.0
def _get_account_stock_move_lines(self, type_,fee=None):
pool = Pool()
Uom = pool.get('product.uom')
AccountMoveLine = pool.get('account.move.line')
Currency = pool.get('currency.currency')
lines = super(Move, self)._get_account_stock_move_lines(type_,fee)
logger.info("FROM_MOVE_GET:%s",lines)
cost_price_method = self.product.get_multivalue(
'cost_price_method', **self._cost_price_pattern)
# if type_.endswith('supplier') and cost_price_method == 'fixed':
# cost_price = Uom.compute_price(
# self.product.default_uom, self.cost_price, self.unit)
# with Transaction().set_context(date=self.effective_date):
# unit_price = Currency.compute(self.currency, self.unit_price,
# self.company.currency, round=False)
# amount = self.company.currency.round(
# Decimal(str(self.quantity)) * (unit_price - cost_price))
# if self.company.currency.is_zero(amount):
# return lines
# account = self.product.account_stock_in_used
# for move_line in lines:
# if move_line.account == account:
# break
# else:
# return lines
# if type_.startswith('in_'):
# move_line.credit += amount
# debit = amount
# credit = Decimal(0)
# else:
# move_line.debit += amount
# debit = Decimal(0)
# credit = amount
# if amount < Decimal(0):
# debit, credit = -credit, -debit
# move_line = AccountMoveLine(
# debit=debit,
# credit=credit,
# account=self.product.account_expense_used,
# )
# lines.append(move_line)
return lines
@classmethod
def _get_anglo_saxon_move(cls, moves, quantity, type_):
'''
Generator of (move, qty, cost_price) where move is the move to be
consumed, qty is the quantity (in the product default uom) to be
consumed on this move and cost_price is in the company currency.
'''
pool = Pool()
Uom = pool.get('product.uom')
Currency = pool.get('currency.currency')
as_qty_field = _get_field(type_)
consumed_qty = 0.0
for move in moves:
qty = Uom.compute_qty(
move.unit,
move.quantity - getattr(move, as_qty_field),
move.product.default_uom, round=False)
if qty <= 0.0:
continue
if qty > quantity - consumed_qty:
qty = quantity - consumed_qty
if consumed_qty >= quantity:
break
# if type_.endswith('supplier'):
# with Transaction().set_context(date=move.effective_date):
# unit_price = Currency.compute(move.currency,
# move.unit_price, move.company.currency, round=False)
# cost_price = Uom.compute_price(
# move.unit, unit_price, move.product.default_uom)
# else:
# cost_price = move.cost_price
cost_price = move.unit_price
yield (move, qty, cost_price)
consumed_qty += qty
@classmethod
def update_anglo_saxon_quantity_product_cost(cls, product, moves,
quantity, unit, type_):
'''
Return the cost for quantity based on lines.
Update anglo_saxon_quantity on the concerned moves.
'''
pool = Pool()
Uom = pool.get('product.uom')
assert all(m.product == product for m in moves), 'wrong product'
assert type_.startswith('in_') or type_.startswith('out_'), \
'wrong type'
total_qty = Uom.compute_qty(
unit, quantity, product.default_uom, round=False)
as_qty_field = _get_field(type_)
cost = Decimal(0)
consumed_qty = 0.0
for move, move_qty, move_cost_price in cls._get_anglo_saxon_move(
moves, total_qty, type_):
consumed_qty += move_qty
logger.info("ANGLO_UPDATE:%s",move_cost_price)
cost += move_cost_price * Decimal(str(move_qty))
move_qty = Uom.compute_qty(
product.default_uom, move_qty, move.unit, round=False)
# Avoid float rounding issue but allow only rounding precision lost
new_qty = (getattr(move, as_qty_field) or 0.0) + move_qty
assert move.unit.round(new_qty) <= move.quantity
new_qty = min(new_qty, move.quantity)
cls.write([move], {
as_qty_field: new_qty,
})
if consumed_qty < total_qty:
qty = total_qty - consumed_qty
consumed_qty += qty
cost += product.cost_price * Decimal(str(qty))
return cost
@classmethod
def copy(cls, moves, default=None):
if default is None:
default = {}
else:
default = default.copy()
for prefix in ('in_', 'out_'):
default.setdefault(prefix + 'anglo_saxon_quantity',
getattr(cls, 'default_%sanglo_saxon_quantity' % prefix)())
return super(Move, cls).copy(moves, default=default)

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,396 @@
==================================
Account Stock Anglo-Saxon Scenario
==================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... create_payment_term, set_fiscalyear_invoice_sequences)
>>> from trytond.modules.account_stock_anglo_saxon.tests.tools import (
... add_cogs_accounts)
>>> from trytond.modules.account_stock_continental.tests.tools import (
... add_stock_accounts)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, set_user
>>> today = dt.date.today()
Activate modules::
>>> config = activate_modules([
... 'account_stock_anglo_saxon',
... 'sale',
... 'purchase',
... ])
Create company::
>>> _ = create_company()
>>> company = get_company()
Create the required users::
>>> User = Model.get('res.user')
>>> Group = Model.get('res.group')
>>> accountant = User()
>>> accountant.name = 'Accountant'
>>> accountant.login = 'accountant'
>>> account_group, = Group.find([('name', '=', 'Account')])
>>> accountant.groups.append(account_group)
>>> accountant.save()
>>> product_user = User()
>>> product_user.name = 'Product User'
>>> product_user.login = 'product_user'
>>> product_group, = Group.find([('name', '=', 'Account Product Administration')])
>>> product_user.groups.append(product_group)
>>> product_user.save()
>>> purchase_user = User()
>>> purchase_user.name = 'Purchase User'
>>> purchase_user.login = 'purchase_user'
>>> purchase_group, = Group.find([('name', '=', 'Purchase')])
>>> purchase_user.groups.append(purchase_group)
>>> purchase_user.save()
>>> stock_user = User()
>>> stock_user.name = 'Sale User'
>>> stock_user.login = 'stock_user'
>>> stock_group, = Group.find([('name', '=', 'Stock')])
>>> stock_user.groups.append(stock_group)
>>> stock_user.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(company, today))
>>> fiscalyear.account_stock_method = 'anglo_saxon'
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = add_cogs_accounts(add_stock_accounts(
... get_accounts(company), company), company)
>>> receivable = accounts['receivable']
>>> payable = accounts['payable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> stock = accounts['stock']
>>> stock_in = accounts['stock_expense']
>>> stock_out, = stock_in.duplicate()
>>> cogs = accounts['cogs']
Create parties::
>>> Party = Model.get('party.party')
>>> supplier = Party(name='Supplier')
>>> supplier.save()
>>> customer = Party(name='Customer')
>>> customer.save()
Create product category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_expense = expense
>>> account_category.account_revenue = revenue
>>> account_category.account_stock = stock
>>> account_category.account_cogs = cogs
>>> account_category.account_stock_in = stock_in
>>> account_category.account_stock_out = stock_out
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.purchasable = True
>>> template.salable = True
>>> template.list_price = Decimal('10')
>>> template.cost_price_method = 'fixed'
>>> template.lead_time = dt.timedelta(0)
>>> template.account_category = account_category
>>> product, = template.products
>>> product.cost_price = Decimal('5')
>>> template.save()
>>> product, = template.products
>>> template_average, = template.duplicate({'cost_price_method': 'average'})
>>> template_average.account_category = account_category
>>> template_average.save()
>>> product_average, = template_average.products
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Purchase 12 products::
>>> Purchase = Model.get('purchase.purchase')
>>> purchase = Purchase()
>>> purchase.party = supplier
>>> purchase.payment_term = payment_term
>>> purchase.invoice_method = 'shipment'
>>> purchase_line = purchase.lines.new()
>>> purchase_line.product = product
>>> purchase_line.quantity = 5.0
>>> purchase_line.unit_price = Decimal(4)
>>> purchase_line = purchase.lines.new()
>>> purchase_line.product = product_average
>>> purchase_line.quantity = 7.0
>>> purchase_line.unit_price = Decimal(6)
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> purchase.state
'processing'
Receive 9 products::
>>> ShipmentIn = Model.get('stock.shipment.in')
>>> Move = Model.get('stock.move')
>>> shipment = ShipmentIn(supplier=supplier)
>>> move, = [m for m in purchase.moves if m.product == product]
>>> move = Move(move.id)
>>> shipment.incoming_moves.append(move)
>>> move.quantity = 4.0
>>> move, = [m for m in purchase.moves if m.product == product_average]
>>> move = Move(move.id)
>>> shipment.incoming_moves.append(move)
>>> move.quantity = 5.0
>>> shipment.click('receive')
>>> shipment.click('do')
>>> shipment.state
'done'
>>> stock_in.reload()
>>> stock.reload()
>>> stock_in.debit
Decimal('0.00')
>>> stock_in.credit
Decimal('46.00')
>>> stock.reload()
>>> stock.debit
Decimal('50.00')
>>> stock.credit
Decimal('0.00')
>>> expense.reload()
>>> expense.debit
Decimal('0.00')
>>> expense.credit
Decimal('4.00')
Open supplier invoice::
>>> Invoice = Model.get('account.invoice')
>>> purchase.reload()
>>> invoice, = purchase.invoices
>>> invoice_line, = [l for l in invoice.lines if l.product == product]
>>> invoice_line.unit_price = Decimal('6')
>>> invoice_line, = [l for l in invoice.lines
... if l.product == product_average]
>>> invoice_line.unit_price = Decimal('4')
>>> invoice.invoice_date = today
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> payable.reload()
>>> payable.debit
Decimal('0.00')
>>> payable.credit
Decimal('44.00')
>>> expense.reload()
>>> expense.debit
Decimal('44.00')
>>> expense.credit
Decimal('50.00')
>>> stock_in.reload()
>>> stock_in.debit
Decimal('46.00')
>>> stock_in.credit
Decimal('46.00')
Sale 5 products::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> sale.payment_term = payment_term
>>> sale.invoice_method = 'shipment'
>>> sale_line = sale.lines.new()
>>> sale_line.product = product
>>> sale_line.quantity = 2.0
>>> sale_line = sale.lines.new()
>>> sale_line.product = product_average
>>> sale_line.quantity = 3.0
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'processing'
Send 5 products::
>>> ShipmentOut = Model.get('stock.shipment.out')
>>> shipment, = sale.shipments
>>> shipment.click('assign_try')
>>> shipment.state
'assigned'
>>> shipment.click('pick')
>>> shipment.state
'picked'
>>> shipment.click('pack')
>>> shipment.state
'packed'
>>> shipment.click('do')
>>> shipment.state
'done'
>>> stock_out.reload()
>>> stock_out.debit
Decimal('28.00')
>>> stock_out.credit
Decimal('0.00')
>>> stock.reload()
>>> stock.debit
Decimal('50.00')
>>> stock.credit
Decimal('28.00')
Open customer invoice::
>>> sale.reload()
>>> invoice, = sale.invoices
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> receivable.reload()
>>> receivable.debit
Decimal('50.00')
>>> receivable.credit
Decimal('0.00')
>>> revenue.reload()
>>> revenue.debit
Decimal('0.00')
>>> revenue.credit
Decimal('50.00')
>>> stock_out.reload()
>>> stock_out.debit
Decimal('28.00')
>>> stock_out.credit
Decimal('28.00')
>>> cogs.reload()
>>> cogs.debit
Decimal('28.00')
>>> cogs.credit
Decimal('0.00')
Now create a supplier invoice with an accountant::
>>> purchase = Purchase()
>>> purchase.party = supplier
>>> purchase.payment_term = payment_term
>>> purchase.invoice_method = 'order'
>>> purchase_line = purchase.lines.new()
>>> purchase_line.product = product
>>> purchase_line.quantity = 5.0
>>> purchase_line.unit_price = Decimal(4)
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> purchase.state
'processing'
>>> set_user(accountant)
>>> for invoice in purchase.invoices:
... invoice.invoice_date = today
>>> Invoice.save(purchase.invoices)
>>> Invoice.click(purchase.invoices, 'validate_invoice')
Create customer invoice with negative quantity::
>>> invoice = Invoice()
>>> invoice.party = customer
>>> invoice.payment_term = payment_term
>>> invoice_line = invoice.lines.new()
>>> invoice_line.product = product
>>> invoice_line.quantity = -1
>>> invoice_line.unit_price = Decimal('10')
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> move = invoice.move
>>> line_cogs, = (l for l in move.lines if l.account == cogs)
>>> line_cogs.credit
Decimal('5.00')
>>> line_stock, = (l for l in move.lines if l.account == stock_in)
>>> line_stock.debit
Decimal('5.00')
Now we will use a product with different unit of measure::
>>> set_user(product_user)
>>> UomCategory = Model.get('product.uom.category')
>>> unit_category, = UomCategory.find([('name', '=', 'Units')])
>>> unit_5 = ProductUom(name='5', symbol='5', category=unit_category,
... factor=5, digits=0, rounding=1)
>>> unit_5.save()
>>> template_by5 = ProductTemplate()
>>> template_by5.name = 'product'
>>> template_by5.default_uom = unit
>>> template_by5.type = 'goods'
>>> template_by5.purchasable = True
>>> template_by5.purchase_uom = unit_5
>>> template_by5.salable = True
>>> template_by5.sale_uom = unit_5
>>> template_by5.list_price = Decimal('10')
>>> template_by5.cost_price_method = 'fixed'
>>> template_by5.lead_time = dt.timedelta(0)
>>> template_by5.account_category = account_category
>>> product_by5, = template_by5.products
>>> product_by5.cost_price = Decimal('5')
>>> template_by5.save()
>>> product_by5, = template_by5.products
>>> set_user(purchase_user)
>>> purchase = Purchase()
>>> purchase.party = supplier
>>> purchase.payment_term = payment_term
>>> purchase.invoice_method = 'shipment'
>>> purchase_line = purchase.lines.new()
>>> purchase_line.product = product_by5
>>> purchase_line.quantity = 1.0
>>> purchase_line.unit_price = Decimal('5.0000')
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> set_user(stock_user)
>>> shipment = ShipmentIn(supplier=supplier)
>>> move = Move(purchase.moves[0].id)
>>> move.in_anglo_saxon_quantity
0.0
>>> shipment.incoming_moves.append(move)
>>> shipment.click('receive')
>>> shipment.click('do')
>>> set_user(accountant)
>>> purchase.reload()
>>> invoice, = purchase.invoices
>>> invoice.invoice_date = today
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> set_user(stock_user)
>>> move = Move(purchase.moves[0].id)
>>> move.in_anglo_saxon_quantity
1.0

View File

@@ -0,0 +1,269 @@
=====================================================
Account Stock Anglo-Saxon with Drop Shipment Scenario
=====================================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... create_payment_term, set_fiscalyear_invoice_sequences)
>>> from trytond.modules.account_stock_anglo_saxon.tests.tools import (
... add_cogs_accounts)
>>> from trytond.modules.account_stock_continental.tests.tools import (
... add_stock_accounts)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, set_user
>>> today = dt.date.today()
Activate modules::
>>> config = activate_modules([
... 'account_stock_anglo_saxon',
... 'sale_supply_drop_shipment',
... 'sale',
... 'purchase',
... ])
Create company::
>>> _ = create_company()
>>> company = get_company()
Create sale user::
>>> User = Model.get('res.user')
>>> Group = Model.get('res.group')
>>> sale_user = User()
>>> sale_user.name = 'Sale'
>>> sale_user.login = 'sale'
>>> sale_group, = Group.find([('name', '=', 'Sales')])
>>> sale_user.groups.append(sale_group)
>>> sale_user.save()
Create purchase user::
>>> purchase_user = User()
>>> purchase_user.name = 'Purchase'
>>> purchase_user.login = 'purchase'
>>> purchase_group, = Group.find([('name', '=', 'Purchase')])
>>> purchase_user.groups.append(purchase_group)
>>> purchase_request_group, = Group.find(
... [('name', '=', 'Purchase Request')])
>>> purchase_user.groups.append(purchase_request_group)
>>> purchase_user.save()
Create stock user::
>>> stock_user = User()
>>> stock_user.name = 'Stock'
>>> stock_user.login = 'stock'
>>> stock_group, = Group.find([('name', '=', 'Stock')])
>>> stock_user.groups.append(stock_group)
>>> stock_user.save()
Create account user::
>>> account_user = User()
>>> account_user.name = 'Account'
>>> account_user.login = 'account'
>>> account_group, = Group.find([('name', '=', 'Account')])
>>> account_user.groups.append(account_group)
>>> account_user.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(company, today))
>>> fiscalyear.account_stock_method = 'anglo_saxon'
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = add_cogs_accounts(add_stock_accounts(
... get_accounts(company), company), company)
>>> receivable = accounts['receivable']
>>> payable = accounts['payable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> stock = accounts['stock']
>>> stock_in = accounts['stock_expense']
>>> stock_out, = stock_in.duplicate()
>>> cogs = accounts['cogs']
Create parties::
>>> Party = Model.get('party.party')
>>> supplier = Party(name='Supplier')
>>> supplier.save()
>>> customer = Party(name='Customer')
>>> customer.save()
Create product category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_expense = expense
>>> account_category.account_revenue = revenue
>>> account_category.account_stock = stock
>>> account_category.account_cogs = cogs
>>> account_category.account_stock_in = stock_in
>>> account_category.account_stock_out = stock_out
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductSupplier = Model.get('purchase.product_supplier')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.purchasable = True
>>> template.salable = True
>>> template.list_price = Decimal('10')
>>> template.cost_price_method = 'fixed'
>>> template.lead_time = dt.timedelta(0)
>>> template.supply_on_sale = 'always'
>>> template.account_category = account_category
>>> product, = template.products
>>> product.cost_price = Decimal('5')
>>> template.save()
>>> product, = template.products
>>> product_supplier = ProductSupplier()
>>> product_supplier.template = template
>>> product_supplier.party = supplier
>>> product_supplier.drop_shipment = True
>>> product_supplier.lead_time = dt.timedelta(0)
>>> product_supplier.save()
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Sale 50 products::
>>> set_user(sale_user)
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> sale.payment_term = payment_term
>>> sale_line = sale.lines.new()
>>> sale_line.product = product
>>> sale_line.quantity = 50
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'processing'
Create Purchase from Request::
>>> set_user(purchase_user)
>>> Purchase = Model.get('purchase.purchase')
>>> PurchaseRequest = Model.get('purchase.request')
>>> purchase_request, = PurchaseRequest.find()
>>> create_purchase = Wizard('purchase.request.create_purchase',
... [purchase_request])
>>> purchase, = Purchase.find()
>>> purchase.payment_term = payment_term
>>> purchase_line, = purchase.lines
>>> purchase_line.unit_price = Decimal('3')
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> purchase.state
'processing'
>>> set_user(sale_user)
>>> sale.reload()
>>> sale.shipments
[]
>>> shipment, = sale.drop_shipments
Receive 50 products::
>>> set_user(stock_user)
>>> shipment.click('ship')
>>> shipment.click('do')
>>> shipment.state
'done'
>>> set_user(account_user)
>>> stock_in.reload()
>>> stock_in.debit
Decimal('0.00')
>>> stock_in.credit
Decimal('150.00')
>>> stock_out.reload()
>>> stock_out.debit
Decimal('150.00')
>>> stock_out.credit
Decimal('0.00')
>>> stock.reload()
>>> stock.debit
Decimal('150.00')
>>> stock.credit
Decimal('150.00')
Open supplier invoice::
>>> set_user(purchase_user)
>>> purchase.reload()
>>> invoice, = purchase.invoices
>>> set_user(account_user)
>>> invoice.invoice_date = today
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> payable.reload()
>>> payable.debit
Decimal('0.00')
>>> payable.credit
Decimal('150.00')
>>> expense.reload()
>>> expense.debit
Decimal('150.00')
>>> expense.credit
Decimal('150.00')
>>> stock_in.reload()
>>> stock_in.debit
Decimal('150.00')
>>> stock_in.credit
Decimal('150.00')
Open customer invoice::
>>> set_user(sale_user)
>>> sale.reload()
>>> invoice, = sale.invoices
>>> set_user(account_user)
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> receivable.reload()
>>> receivable.debit
Decimal('500.00')
>>> receivable.credit
Decimal('0.00')
>>> revenue.reload()
>>> revenue.debit
Decimal('0.00')
>>> revenue.credit
Decimal('500.00')
>>> stock_out.reload()
>>> stock_out.debit
Decimal('150.00')
>>> stock_out.credit
Decimal('150.00')
>>> cogs.reload()
>>> cogs.debit
Decimal('150.00')
>>> cogs.credit
Decimal('0.00')

View File

@@ -0,0 +1,50 @@
# 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 unittest.mock import Mock, patch
from trytond.pool import Pool
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
class AccountStockAngloSaxonTestCase(ModuleTestCase):
'Test Account Stock Anglo Saxon module'
module = 'account_stock_anglo_saxon'
@with_transaction()
def test_get_anglo_saxon_move(self):
'Test _get_anglo_saxon_move'
pool = Pool()
Move = pool.get('stock.move')
Uom = pool.get('product.uom')
Currency = pool.get('currency.currency')
def move(quantity, price):
move = Mock()
move.quantity = quantity
move.unit_price = price
move.cost_price = price
move.in_anglo_saxon_quantity = 0
move.out_anglo_saxon_quantity = 0
return move
with patch.object(Uom, 'compute_qty') as compute_qty, \
patch.object(Uom, 'compute_price') as compute_price, \
patch.object(Currency, 'compute') as compute:
compute_qty.side_effect = lambda *args, **kwargs: args[1]
compute_price.side_effect = lambda *args, **kwargs: args[1]
compute.side_effect = lambda *args, **kwargs: args[1]
moves = [move(1, 3), move(2, 2)]
result = list(Move._get_anglo_saxon_move(
moves, 1, 'in_supplier'))
self.assertEqual(result, [(moves[0], 1, 3)])
moves = [move(1, 3), move(2, 2)]
result = list(Move._get_anglo_saxon_move(
moves, 2, 'in_supplier'))
self.assertEqual(result,
[(moves[0], 1, 3), (moves[1], 1, 2)])
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# 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.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)

View File

@@ -0,0 +1,19 @@
# 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 proteus import Model
from trytond.modules.company.tests.tools import get_company
def add_cogs_accounts(accounts, company=None, config=None):
"Add COGS to accounts"
Account = Model.get('account.account', config=config)
if not company:
company = get_company(config=config)
accounts['cogs'], = Account.find([
('type.expense', '=', True),
('id', '!=', accounts['expense'].id),
('company', '=', company.id),
])
return accounts

View File

@@ -0,0 +1,23 @@
[tryton]
version=7.2.1
depends:
account
account_invoice
account_invoice_stock
account_product
account_stock_continental
ir
res
xml:
product.xml
minimal_chart_bg.xml
minimal_chart_ca.xml
minimal_chart_de.xml
minimal_chart_en.xml
minimal_chart_es.xml
minimal_chart_fr.xml
minimal_chart_nl.xml
minimal_chart_pt.xml
minimal_chart_ru.xml
minimal_chart_sl.xml
message.xml

View File

@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath
expr="/form/notebook/page[@id='accounting']/field[@name='account_stock']"
position="after">
<label name="account_cogs"/>
<field name="account_cogs"/>
</xpath>
</data>