Add domains in journal field. Add shops field in journal model and view

This commit is contained in:
Jordi Esteve 2015-03-06 19:11:02 +01:00
parent b577ad4eb6
commit d610f589b7
8 changed files with 52 additions and 2 deletions

View File

@ -3,10 +3,13 @@
# copyright notices and license terms.
from trytond.pool import Pool
from .shop import *
from .journal import *
from .sale import *
def register():
Pool.register(
Journal,
SaleShop,
Sale,
module='sale_shop_invoice_journal', type_='model')

17
journal.py Normal file
View File

@ -0,0 +1,17 @@
# This file is part of sale_shop_invoice_journal module for 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.pyson import Eval
from trytond.pool import PoolMeta
__all__ = ['Journal']
__metaclass__ = PoolMeta
class Journal:
__name__ = 'account.journal'
shops = fields.One2Many('sale.shop', 'journal', 'Shops',
states={
'invisible': Eval('type') != 'revenue',
}, depends=['type'])

BIN
journal.pyc Normal file

Binary file not shown.

14
journal.xml Normal file
View File

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

View File

@ -10,7 +10,8 @@ __metaclass__ = PoolMeta
class Sale:
__name__ = 'sale.sale'
journal = fields.Many2One('account.journal', 'Account Journal')
journal = fields.Many2One('account.journal', 'Account Journal',
domain=[('type', '=', 'revenue')])
def _get_invoice_sale(self, invoice_type):
invoice = super(Sale, self)._get_invoice_sale(invoice_type)

View File

@ -10,4 +10,5 @@ __metaclass__ = PoolMeta
class SaleShop:
__name__ = 'sale.shop'
journal = fields.Many2One('account.journal', 'Account Journal')
journal = fields.Many2One('account.journal', 'Account Journal',
domain=[('type', '=', 'revenue')])

View File

@ -7,4 +7,5 @@ depends:
account_invoice_multisequence
xml:
shop.xml
journal.xml
sale.xml

13
view/journal_form.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- This file is part of the sale_shop_invoice_journal module for 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='sequences']" position="after">
<page string="Shops"
states="{'invisible': Eval('type') != 'revenue'}"
id="shops">
<field name="shops" colspan="4" widget="many2many"/>
</page>
</xpath>
</data>