first commit
This commit is contained in:
2
modules/commission_waiting/__init__.py
Normal file
2
modules/commission_waiting/__init__.py
Normal 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.
|
||||
BIN
modules/commission_waiting/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/commission_waiting/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/commission_waiting/__pycache__/account.cpython-311.pyc
Normal file
BIN
modules/commission_waiting/__pycache__/account.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
modules/commission_waiting/__pycache__/invoice.cpython-311.pyc
Normal file
BIN
modules/commission_waiting/__pycache__/invoice.cpython-311.pyc
Normal file
Binary file not shown.
12
modules/commission_waiting/account.py
Normal file
12
modules/commission_waiting/account.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# 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 Move(metaclass=PoolMeta):
|
||||
__name__ = 'account.move'
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
return super()._get_origin() + ['commission']
|
||||
97
modules/commission_waiting/commission.py
Normal file
97
modules/commission_waiting/commission.py
Normal file
@@ -0,0 +1,97 @@
|
||||
# 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.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Bool, Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class Agent(metaclass=PoolMeta):
|
||||
__name__ = 'commission.agent'
|
||||
waiting_account = fields.Many2One('account.account', 'Waiting Account',
|
||||
domain=[
|
||||
('type', '!=', None),
|
||||
('closed', '!=', True),
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
help="The account the agent's waiting commission amounts are posted "
|
||||
"to.")
|
||||
|
||||
|
||||
class Commission(metaclass=PoolMeta):
|
||||
__name__ = 'commission'
|
||||
waiting_move = fields.Many2One(
|
||||
'account.move', "Waiting Move", readonly=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.amount.states['readonly'] |= Bool(Eval('waiting_move'))
|
||||
|
||||
@classmethod
|
||||
def copy(cls, commissions, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default.setdefault('waiting_move', None)
|
||||
return super().copy(commissions, default=default)
|
||||
|
||||
@classmethod
|
||||
def create_waiting_move(cls, commissions):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
Commission = pool.get('commission')
|
||||
moves = []
|
||||
for commission in commissions:
|
||||
move = commission.get_move()
|
||||
if move:
|
||||
moves.append(move)
|
||||
commission.waiting_move = move
|
||||
|
||||
Move.save(moves)
|
||||
Commission.save(commissions)
|
||||
|
||||
def get_move(self, date=None):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
Line = pool.get('account.move.line')
|
||||
Date = pool.get('ir.date')
|
||||
Period = pool.get('account.period')
|
||||
Currency = pool.get('currency.currency')
|
||||
|
||||
if not self.agent.waiting_account:
|
||||
return
|
||||
if self.waiting_move:
|
||||
return self.waiting_move
|
||||
|
||||
if date is None:
|
||||
with Transaction().set_context(company=self.agent.company.id):
|
||||
date = Date.today()
|
||||
period = Period.find(self.agent.company, date=date)
|
||||
|
||||
move = Move(journal=self.get_journal(), origin=self,
|
||||
date=date, period=period, company=self.agent.company)
|
||||
amount = Currency.compute(self.currency, self.amount,
|
||||
self.agent.company.currency)
|
||||
line = Line()
|
||||
with Transaction().set_context(date=date):
|
||||
if self.type_ == 'in':
|
||||
line.credit = amount if amount > 0 else 0
|
||||
line.debit = amount if amount < 0 else 0
|
||||
line.account = self.product.account_revenue_used
|
||||
else:
|
||||
line.debit = amount if amount > 0 else 0
|
||||
line.credit = amount if amount < 0 else 0
|
||||
line.account = self.product.account_expense_used
|
||||
if line.account.party_required:
|
||||
line.party = self.agent.party
|
||||
# XXX second currency?
|
||||
counterpart = Line()
|
||||
counterpart.debit, counterpart.credit = line.credit, line.debit
|
||||
counterpart.account = self.agent.waiting_account
|
||||
if counterpart.account.party_required:
|
||||
counterpart.party = self.agent.party
|
||||
move.lines = (line, counterpart)
|
||||
return move
|
||||
18
modules/commission_waiting/commission.xml
Normal file
18
modules/commission_waiting/commission.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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="agent_view_form">
|
||||
<field name="model">commission.agent</field>
|
||||
<field name="inherit" ref="commission.agent_view_form"/>
|
||||
<field name="name">agent_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="commission_view_form">
|
||||
<field name="model">commission</field>
|
||||
<field name="inherit" ref="commission.commission_view_form"/>
|
||||
<field name="name">commission_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
67
modules/commission_waiting/invoice.py
Normal file
67
modules/commission_waiting/invoice.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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 collections import defaultdict
|
||||
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice'
|
||||
|
||||
@classmethod
|
||||
def _post(cls, invoices):
|
||||
super()._post(invoices)
|
||||
cls.post_commission_waiting_moves(invoices)
|
||||
|
||||
@classmethod
|
||||
def create_commissions(cls, invoices):
|
||||
pool = Pool()
|
||||
Commission = pool.get('commission')
|
||||
|
||||
commissions = super().create_commissions(invoices)
|
||||
|
||||
Commission.create_waiting_move(commissions)
|
||||
return commissions
|
||||
|
||||
@classmethod
|
||||
def post_commission_waiting_moves(cls, invoices):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
|
||||
moves = []
|
||||
for invoice in invoices:
|
||||
for line in invoice.lines:
|
||||
for commission in line.from_commissions:
|
||||
if (commission.waiting_move
|
||||
and commission.waiting_move.state != 'posted'):
|
||||
moves.append(commission.waiting_move)
|
||||
if moves:
|
||||
Move.post(moves)
|
||||
|
||||
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
def get_move_lines(self):
|
||||
pool = Pool()
|
||||
MoveLine = pool.get('account.move.line')
|
||||
|
||||
lines = super().get_move_lines()
|
||||
if self.from_commissions:
|
||||
amounts = defaultdict(int)
|
||||
for commission in self.from_commissions:
|
||||
if not commission.waiting_move:
|
||||
continue
|
||||
for line in commission.waiting_move.lines:
|
||||
amounts[(line.account, line.party)] += (
|
||||
line.debit - line.credit)
|
||||
for (account, party), amount in amounts.items():
|
||||
line = MoveLine()
|
||||
line.debit = -amount if amount < 0 else 0
|
||||
line.credit = amount if amount > 0 else 0
|
||||
line.account = account
|
||||
line.party = party
|
||||
line.amount_second_currency = None
|
||||
lines.append(line)
|
||||
return lines
|
||||
15
modules/commission_waiting/locale/bg.po
Normal file
15
modules/commission_waiting/locale/bg.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
17
modules/commission_waiting/locale/ca.po
Normal file
17
modules/commission_waiting/locale/ca.po
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Assentament d'espera"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Compte d'espera"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"El compte on es contabilitzarant els imports de ocmisions en espera de "
|
||||
"l'agent."
|
||||
15
modules/commission_waiting/locale/cs.po
Normal file
15
modules/commission_waiting/locale/cs.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/de.po
Normal file
16
modules/commission_waiting/locale/de.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Sammelbuchung"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Sammelkonto"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"Das Konto, auf dem die auszuzahlenden Provisionsbeträge gesammelt werden."
|
||||
17
modules/commission_waiting/locale/es.po
Normal file
17
modules/commission_waiting/locale/es.po
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Asiento de espera"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Cuenta de espera"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"La cuenta en la que se contabilizan los importes de comisiones en espera del"
|
||||
" agente."
|
||||
15
modules/commission_waiting/locale/es_419.po
Normal file
15
modules/commission_waiting/locale/es_419.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/et.po
Normal file
16
modules/commission_waiting/locale/et.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Vahekonto"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Vahekonto"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/fa.po
Normal file
16
modules/commission_waiting/locale/fa.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "حساب در انتظار"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "حساب در انتظار"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
15
modules/commission_waiting/locale/fi.po
Normal file
15
modules/commission_waiting/locale/fi.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
17
modules/commission_waiting/locale/fr.po
Normal file
17
modules/commission_waiting/locale/fr.po
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Mouvement d'attente"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Compte d'attente"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"Le compte sur lequel les montants des commissions en attente de l'agent sont"
|
||||
" comptabilisés."
|
||||
15
modules/commission_waiting/locale/hu.po
Normal file
15
modules/commission_waiting/locale/hu.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/id.po
Normal file
16
modules/commission_waiting/locale/id.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Akun Tunggu"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Akun Tunggu"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
17
modules/commission_waiting/locale/it.po
Normal file
17
modules/commission_waiting/locale/it.po
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Movimento in attesa"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "conto attesa"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"Il conto in cui vengono registrati gli importi delle commissioni in attesa "
|
||||
"dell'agente."
|
||||
16
modules/commission_waiting/locale/lo.po
Normal file
16
modules/commission_waiting/locale/lo.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "ບັນຊີລໍຖ້າ"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "ບັນຊີລໍຖ້າ"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
15
modules/commission_waiting/locale/lt.po
Normal file
15
modules/commission_waiting/locale/lt.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
17
modules/commission_waiting/locale/nl.po
Normal file
17
modules/commission_waiting/locale/nl.po
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "wacht boeking"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "wachtrekening"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"De rekening waarop de wachtende commissiebedragen van de agent worden "
|
||||
"geboekt."
|
||||
15
modules/commission_waiting/locale/pl.po
Normal file
15
modules/commission_waiting/locale/pl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/pt.po
Normal file
16
modules/commission_waiting/locale/pt.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Conta de Espera"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Conta de Espera"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/ro.po
Normal file
16
modules/commission_waiting/locale/ro.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Mișcare în așteptare"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Cont de așteptare"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
"Conturile in care este postat comisionul al agentului in care de așteptare."
|
||||
15
modules/commission_waiting/locale/ru.po
Normal file
15
modules/commission_waiting/locale/ru.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
16
modules/commission_waiting/locale/sl.po
Normal file
16
modules/commission_waiting/locale/sl.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr "Čakalni konto"
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr "Čakalni konto"
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
15
modules/commission_waiting/locale/tr.po
Normal file
15
modules/commission_waiting/locale/tr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
15
modules/commission_waiting/locale/uk.po
Normal file
15
modules/commission_waiting/locale/uk.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
15
modules/commission_waiting/locale/zh_CN.po
Normal file
15
modules/commission_waiting/locale/zh_CN.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:commission,waiting_move:"
|
||||
msgid "Waiting Move"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:commission.agent,waiting_account:"
|
||||
msgid "Waiting Account"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:commission.agent,waiting_account:"
|
||||
msgid "The account the agent's waiting commission amounts are posted to."
|
||||
msgstr ""
|
||||
2
modules/commission_waiting/tests/__init__.py
Normal file
2
modules/commission_waiting/tests/__init__.py
Normal 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.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
155
modules/commission_waiting/tests/scenario_commission_waiting.rst
Normal file
155
modules/commission_waiting/tests/scenario_commission_waiting.rst
Normal file
@@ -0,0 +1,155 @@
|
||||
===================
|
||||
Commission 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.company.tests.tools import create_company, get_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('commission_waiting', create_company, create_chart)
|
||||
|
||||
Get company::
|
||||
|
||||
>>> company = get_company()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create waiting account::
|
||||
|
||||
>>> Account = Model.get('account.account')
|
||||
>>> waiting_account = Account(name='Waiting Commission')
|
||||
>>> waiting_account.type = accounts['payable'].type
|
||||
>>> waiting_account.reconcile = True
|
||||
>>> waiting_account.deferral = True
|
||||
>>> waiting_account.party_required = False
|
||||
>>> waiting_account.save()
|
||||
|
||||
Create customer::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = accounts['expense']
|
||||
>>> account_category.account_revenue = accounts['revenue']
|
||||
>>> account_category.save()
|
||||
|
||||
Create commission product::
|
||||
|
||||
>>> Uom = Model.get('product.uom')
|
||||
>>> Template = Model.get('product.template')
|
||||
>>> unit, = Uom.find([('name', '=', 'Unit')])
|
||||
>>> template = Template()
|
||||
>>> template.name = 'Commission'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal(0)
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> commission_product, = template.products
|
||||
|
||||
Create commission plan::
|
||||
|
||||
>>> Plan = Model.get('commission.plan')
|
||||
>>> plan = Plan(name='Plan')
|
||||
>>> plan.commission_product = commission_product
|
||||
>>> plan.commission_method = 'payment'
|
||||
>>> line = plan.lines.new()
|
||||
>>> line.formula = 'amount * 0.1'
|
||||
>>> plan.save()
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Create agent::
|
||||
|
||||
>>> Agent = Model.get('commission.agent')
|
||||
>>> agent_party = Party(name='Agent')
|
||||
>>> agent_party.supplier_payment_term = payment_term
|
||||
>>> agent_party.save()
|
||||
>>> agent = Agent(party=agent_party)
|
||||
>>> agent.type_ = 'agent'
|
||||
>>> agent.plan = plan
|
||||
>>> agent.currency = company.currency
|
||||
>>> agent.waiting_account = waiting_account
|
||||
>>> agent.save()
|
||||
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.party = customer
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> invoice.agent = agent
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.description = 'Test'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('100.00')
|
||||
>>> invoice.save()
|
||||
|
||||
Post invoice::
|
||||
|
||||
>>> invoice.click('post')
|
||||
>>> line, = invoice.lines
|
||||
>>> commission, = line.commissions
|
||||
>>> bool(commission.waiting_move)
|
||||
True
|
||||
>>> waiting_account.reload()
|
||||
>>> waiting_account.balance
|
||||
Decimal('-10.00')
|
||||
>>> accounts['payable'].reload()
|
||||
>>> accounts['payable'].balance
|
||||
Decimal('0.00')
|
||||
>>> accounts['expense'].reload()
|
||||
>>> accounts['expense'].balance
|
||||
Decimal('10.00')
|
||||
|
||||
Create commission invoices::
|
||||
|
||||
>>> create_invoice = Wizard('commission.create_invoice')
|
||||
>>> create_invoice.form.from_ = None
|
||||
>>> create_invoice.form.to = None
|
||||
>>> create_invoice.execute('create_')
|
||||
|
||||
>>> invoice, = Invoice.find([('state', '=', 'draft')])
|
||||
>>> invoice.invoice_date = today
|
||||
>>> invoice.click('post')
|
||||
|
||||
>>> waiting_account.reload()
|
||||
>>> waiting_account.balance
|
||||
Decimal('0.00')
|
||||
>>> accounts['payable'].reload()
|
||||
>>> accounts['payable'].balance
|
||||
Decimal('-10.00')
|
||||
>>> accounts['expense'].reload()
|
||||
>>> accounts['expense'].balance
|
||||
Decimal('10.00')
|
||||
12
modules/commission_waiting/tests/test_module.py
Normal file
12
modules/commission_waiting/tests/test_module.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# 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 ModuleTestCase
|
||||
|
||||
|
||||
class CommissionWaitingTestCase(ModuleTestCase):
|
||||
'Test Commission Waiting module'
|
||||
module = 'commission_waiting'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/commission_waiting/tests/test_scenario.py
Normal file
8
modules/commission_waiting/tests/test_scenario.py
Normal 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)
|
||||
17
modules/commission_waiting/tryton.cfg
Normal file
17
modules/commission_waiting/tryton.cfg
Normal file
@@ -0,0 +1,17 @@
|
||||
[tryton]
|
||||
version=7.8.0
|
||||
depends:
|
||||
account
|
||||
account_invoice
|
||||
commission
|
||||
ir
|
||||
xml:
|
||||
commission.xml
|
||||
|
||||
[register]
|
||||
model:
|
||||
commission.Agent
|
||||
commission.Commission
|
||||
invoice.Invoice
|
||||
invoice.InvoiceLine
|
||||
account.Move
|
||||
9
modules/commission_waiting/view/agent_form.xml
Normal file
9
modules/commission_waiting/view/agent_form.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?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/field[@name='currency']" position="after">
|
||||
<label name="waiting_account"/>
|
||||
<field name="waiting_account"/>
|
||||
</xpath>
|
||||
</data>
|
||||
10
modules/commission_waiting/view/commission_form.xml
Normal file
10
modules/commission_waiting/view/commission_form.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?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/field[@name='origin']" position="after">
|
||||
<newline/>
|
||||
<label name="waiting_move"/>
|
||||
<field name="waiting_move"/>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in New Issue
Block a user