add valued fields to incoming shipment and add funcionality to incoming shipment

This commit is contained in:
?ngel ?lvarez 2014-04-28 10:51:08 +02:00
parent 83d5413dbe
commit abe4409d83
8 changed files with 115 additions and 7 deletions

View file

@ -1,5 +1,5 @@
#This file is part stock_valued module for Tryton.
#The COPYRIGHT file at the top level of this repository contains
#The COPYRIGHT file at the top level of this repository contains
#the full copyright notices and license terms.
from trytond.pool import Pool
from .move import *
@ -9,5 +9,6 @@ from .shipment import *
def register():
Pool.register(
Move,
ShipmentIn,
ShipmentOut,
module='stock_valued', type_='model')

12
move.py
View file

@ -41,10 +41,18 @@ class Move:
depends=['currency_digits', 'state']),
'get_tax_amount')
total_amount = fields.Function(fields.Numeric('Total Amount',
digits=(16, Eval('currency_digits', 2)), states=STATES,
depends=['currency_digits', 'state']),
digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits']),
'get_total_amount')
@classmethod
def __setup__(cls):
super(Move, cls).__setup__()
unit_price_invisible = cls.unit_price.states.get('invisible')
if unit_price_invisible:
cls.unit_price.states['readonly'] = unit_price_invisible
cls.unit_price.states['invisible'] = {}
@staticmethod
def default_currency_digits():
Company = Pool().get('company.company')

View file

@ -8,12 +8,11 @@ from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from decimal import Decimal
__all__ = ['ShipmentOut']
__all__ = ['ShipmentIn', 'ShipmentOut']
__metaclass__ = PoolMeta
class ShipmentOut:
__name__ = 'stock.shipment.out'
class ShipmentValuedMixin:
currency = fields.Function(fields.Many2One('currency.currency', 'Currency',
on_change_with=['company']),
'on_change_with_currency')
@ -116,3 +115,42 @@ class ShipmentOut:
if key not in names:
del result[key]
return result
class ShipmentIn(ShipmentValuedMixin):
__name__ = 'stock.shipment.in'
@classmethod
def create(cls, shipments):
shipments = super(ShipmentIn, cls).create(shipments)
for shipment in shipments:
cls.write([shipment], shipment.calc_amounts())
return shipments
@classmethod
def receive(cls, shipments):
super(ShipmentIn, cls).receive(shipments)
for shipment in shipments:
cls.write([shipment], shipment.calc_amounts())
class ShipmentOut(ShipmentValuedMixin):
__name__ = 'stock.shipment.out'
@classmethod
def wait(cls, shipments):
super(ShipmentOut, cls).wait(shipments)
for shipment in shipments:
cls.write([shipment], shipment.calc_amounts())
@classmethod
def assign(cls, shipments):
super(ShipmentOut, cls).assign(shipments)
for shipment in shipments:
cls.write([shipment], shipment.calc_amounts())
@classmethod
def pack(cls, shipments):
super(ShipmentOut, cls).pack(shipments)
for shipment in shipments:
cls.write([shipment], shipment.calc_amounts())

28
stock.xml Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tryton>
<data>
<!-- stock.move -->
<record model="ir.ui.view" id="stock_move_view_list">
<field name="model">stock.move</field>
<field name="inherit" ref="stock.move_view_tree"/>
<field name="name">stock_move_list</field>
</record>
<!-- stock.shipment.out -->
<record model="ir.ui.view" id="shipment_out_view_form">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_form"/>
<field name="name">shipment_amounts</field>
</record>
<!-- stock.shipment.in -->
<record model="ir.ui.view" id="shipment_in_view_form">
<field name="model">stock.shipment.in</field>
<field name="inherit" ref="stock.shipment_in_view_form"/>
<field name="name">shipment_amounts</field>
</record>
</data>
</tryton>

View file

@ -12,7 +12,7 @@ if os.path.isdir(DIR):
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import test_depends
from trytond.tests.test_tryton import test_depends, test_view
class StockValuedTestCase(unittest.TestCase):
@ -23,6 +23,12 @@ class StockValuedTestCase(unittest.TestCase):
def setUp(self):
trytond.tests.test_tryton.install_module('stock_valued')
def test0005view(self):
'''
Test view.
'''
test_view('stock_valued')
def test0006depends(self):
'''
Test depends.

View file

@ -6,3 +6,4 @@ depends:
account_invoice
stock
xml:
stock.xml

17
view/shipment_amounts.xml Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="after">
<group col="4" colspan="4" id="shipment_totals">
<label name="untaxed_amount"/>
<field name="untaxed_amount"/>
<label name="currency"/>
<field name="currency"/>
<label name="tax_amount"/>
<field name="tax_amount"/>
<label name="total_amount"/>
<field name="total_amount"/>
</group>
</xpath>
</data>

9
view/stock_move_list.xml Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='uom']" position="after">
<field name="unit_price"/>
<field name="total_amount"/>
</xpath>
</data>