parent
0a07636dd4
commit
8e10e269c9
|
@ -1,6 +1,7 @@
|
|||
# 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 configuration
|
||||
from . import party
|
||||
from . import invoice
|
||||
from . import sale
|
||||
|
@ -14,6 +15,7 @@ def register():
|
|||
invoice.Invoice,
|
||||
module='commission_party', type_='model')
|
||||
Pool.register(
|
||||
configuration.SaleConfiguration,
|
||||
sale.Sale,
|
||||
module='commission_party', type_='model',
|
||||
depends=['sale'])
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
|
||||
__all__ = ['SaleConfiguration']
|
||||
|
||||
|
||||
class SaleConfiguration(metaclass=PoolMeta):
|
||||
__name__ = 'sale.configuration'
|
||||
agent_party = fields.Selection([
|
||||
('party', 'Party'),
|
||||
('shipment_party', 'Shipment Party'),
|
||||
], 'Agent Party', help='Default Agent Party')
|
||||
|
||||
@staticmethod
|
||||
def default_agent_party():
|
||||
return 'party'
|
|
@ -0,0 +1,12 @@
|
|||
<?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 depends="sale">
|
||||
<record model="ir.ui.view" id="sale_configuration_view_form">
|
||||
<field name="model">sale.configuration</field>
|
||||
<field name="inherit" ref="sale.sale_configuration_view_form"/>
|
||||
<field name="name">sale_configuration_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
62
locale/ca.po
62
locale/ca.po
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
|
@ -10,6 +10,66 @@ msgctxt "field:party.party,agent:"
|
|||
msgid "Agent"
|
||||
msgstr "Agent"
|
||||
|
||||
msgctxt "field:party.party,agents:"
|
||||
msgid "Agents"
|
||||
msgstr "Agents"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,agent:"
|
||||
msgid "Agent"
|
||||
msgstr "Agent"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,company:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Data de creació"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuari de creació"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,id:"
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,rec_name:"
|
||||
msgid "Record Name"
|
||||
msgstr "Nom del registre"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Usuari de creació"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuari de modificació"
|
||||
|
||||
msgctxt "field:sale.configuration,agent_party:"
|
||||
msgid "Agent Party"
|
||||
msgstr "Agent del tercer"
|
||||
|
||||
msgctxt "help:sale.configuration,agent_party:"
|
||||
msgid "Default Agent Party"
|
||||
msgstr "Agent del tercer per defecte"
|
||||
|
||||
msgctxt "model:party.party.commission.agent,name:"
|
||||
msgid "Party Commission Agent"
|
||||
msgstr "Comissió agent del tercer"
|
||||
|
||||
msgctxt "selection:sale.configuration,agent_party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercer"
|
||||
|
||||
msgctxt "selection:sale.configuration,agent_party:"
|
||||
msgid "Shipment Party"
|
||||
msgstr "Tercer de l'enviament"
|
||||
|
||||
msgctxt "view:party.party:"
|
||||
msgid "Commissions"
|
||||
msgstr "Comisions"
|
||||
|
|
62
locale/es.po
62
locale/es.po
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
|
@ -10,6 +10,66 @@ msgctxt "field:party.party,agent:"
|
|||
msgid "Agent"
|
||||
msgstr "Agente"
|
||||
|
||||
msgctxt "field:party.party,agents:"
|
||||
msgid "Agents"
|
||||
msgstr "Agentes"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,agent:"
|
||||
msgid "Agent"
|
||||
msgstr "Agente"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,company:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Fecha de creación"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuario de creación"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,id:"
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,rec_name:"
|
||||
msgid "Record Name"
|
||||
msgstr "Nombre del registro"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Usuario de creación"
|
||||
|
||||
msgctxt "field:party.party.commission.agent,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuario de modificación"
|
||||
|
||||
msgctxt "field:sale.configuration,agent_party:"
|
||||
msgid "Agent Party"
|
||||
msgstr "Agente del tercero"
|
||||
|
||||
msgctxt "help:sale.configuration,agent_party:"
|
||||
msgid "Default Agent Party"
|
||||
msgstr "Agente del tercero por defecto"
|
||||
|
||||
msgctxt "model:party.party.commission.agent,name:"
|
||||
msgid "Party Commission Agent"
|
||||
msgstr "Comisión agente tercero"
|
||||
|
||||
msgctxt "selection:sale.configuration,agent_party:"
|
||||
msgid "Party"
|
||||
msgstr "Tercero"
|
||||
|
||||
msgctxt "selection:sale.configuration,agent_party:"
|
||||
msgid "Shipment Party"
|
||||
msgstr "Tercero del envío"
|
||||
|
||||
msgctxt "view:party.party:"
|
||||
msgid "Commissions"
|
||||
msgstr "Comisiones"
|
||||
|
|
28
sale.py
28
sale.py
|
@ -1,7 +1,7 @@
|
|||
# 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 PoolMeta
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
__all__ = ['Sale', 'Opportunity']
|
||||
|
||||
|
@ -9,18 +9,36 @@ __all__ = ['Sale', 'Opportunity']
|
|||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
|
||||
def set_agent_party(self, type='party'):
|
||||
if self.shipment_party:
|
||||
return True
|
||||
return False if self.agent else True
|
||||
|
||||
@fields.depends('party', 'agent')
|
||||
def on_change_party(self):
|
||||
Config = Pool().get('sale.configuration')
|
||||
|
||||
super(Sale, self).on_change_party()
|
||||
if self.party and self.party.agent and not self.agent:
|
||||
self.agent = self.party.agent
|
||||
|
||||
config = Config(1)
|
||||
agent_party = config.agent_party if config.agent_party else 'party'
|
||||
set_agent_party = self.set_agent_party(type=agent_party)
|
||||
|
||||
if set_agent_party and getattr(self, agent_party):
|
||||
self.agent = getattr(self, agent_party).agent
|
||||
|
||||
|
||||
class Opportunity(metaclass=PoolMeta):
|
||||
__name__ = 'sale.opportunity'
|
||||
|
||||
def _get_sale_opportunity(self):
|
||||
Config = Pool().get('sale.configuration')
|
||||
|
||||
sale = super(Opportunity, self)._get_sale_opportunity()
|
||||
if self.party and self.party.agent:
|
||||
sale.agent = self.party.agent
|
||||
|
||||
config = Config(1)
|
||||
agent_party = config.agent_party if config.agent_party else 'party'
|
||||
|
||||
if getattr(self, agent_party):
|
||||
sale.agent = getattr(self, agent_party).agent
|
||||
return sale
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
import unittest
|
||||
import trytond.tests.test_tryton
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
from trytond.tests.test_tryton import suite as test_suite
|
||||
|
||||
|
||||
class TestCase(ModuleTestCase):
|
||||
'Test module'
|
||||
class CommissionPartyTestCase(ModuleTestCase):
|
||||
'Test Commission Party module'
|
||||
module = 'commission_party'
|
||||
|
||||
|
||||
def suite():
|
||||
suite = trytond.tests.test_tryton.suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase))
|
||||
suite = test_suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
CommissionPartyTestCase))
|
||||
return suite
|
||||
|
|
|
@ -7,4 +7,5 @@ extras_depend:
|
|||
sale
|
||||
sale_opportunity
|
||||
xml:
|
||||
configuration.xml
|
||||
party.xml
|
||||
|
|
|
@ -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='sale_shipment_method']" position="after">
|
||||
<label name="agent_party" />
|
||||
<field name="agent_party" />
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue