Skip to content

Commit

Permalink
Merge 5b26761 into 468ca96
Browse files Browse the repository at this point in the history
  • Loading branch information
feiyu4581 committed Apr 1, 2016
2 parents 468ca96 + 5b26761 commit 7ffdb27
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 60 deletions.
8 changes: 8 additions & 0 deletions buy/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,19 @@ def onchange_discount_rate(self):
if self.discount_rate:
self.discount_amount = total * self.discount_rate * 0.01

def get_move_origin(self, vals):
return self._name + (self.env.context.get('is_return') and '.return' or '.sell')

@api.model
def create(self, vals):
'''创建采购入库单时生成有序编号'''
if vals.get('name', '/') == '/':
vals['name'] = self.env['ir.sequence'].get(self._name) or '/'

vals.update({
'origin': self.get_move_origin(vals)
})

return super(buy_receipt, self).create(vals)

@api.one
Expand Down
1 change: 0 additions & 1 deletion core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class res_company(models.Model):
quantity_digits = fields.Integer(u'数量小数位')
amount_digits = fields.Integer(u'单价小数位')
cost_method = fields.Selection(CORE_COST_METHOD, u'存货计价方法')
negtive_quantity = fields.Boolean(u'是否检查负库存')
draft_invoice = fields.Boolean(u'根据发票确认应收应付')


Expand Down
21 changes: 10 additions & 11 deletions core/core_view.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0"?>
<openerp>
<data>

<!--根菜单-->

<menuitem id='setting_menu' name='配置'/>

<menuitem id='master_data_menu' name='基础资料' parent='setting_menu' sequence='10'/>
<menuitem id='config_data_menu' name='辅助资料' parent='setting_menu' sequence='20'/>
<menuitem id='system_menu' name='高级配置' parent='setting_menu' sequence='30'/>

<!--类别-->

<record id="core_category_tree" model="ir.ui.view">
<field name="name">core.category.tree</field>
<field name="model">core.category</field>
Expand All @@ -22,15 +22,15 @@
</tree>
</field>
</record>

<record id="core_category_action" model="ir.actions.act_window">
<field name="name">类别</field>
<field name="res_model">core.category</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>

<menuitem id='core_category_menu' action='core_category_action' parent='config_data_menu' sequence='10'/>

<!--可选值-->
Expand All @@ -52,16 +52,16 @@
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>

<menuitem id='core_value_menu' action='core_value_action' parent='config_data_menu' sequence='900'/>

<!--系统参数-->
<record id="company_form" model="ir.ui.view">
<field name="name">company.form</field>
<field name="model">res.company</field>
<field name="arch" type="xml">
<form string="系统参数" create='0'>
<group string="基础参数">
<group string="基础参数">
<field name="name"/>
<field name="street"/>
<field name="phone"/>
Expand All @@ -72,7 +72,6 @@
<field name="quantity_digits"/>
<field name="amount_digits"/>
<field name="cost_method"/>
<field name="negtive_quantity"/>
<field name="draft_invoice"/>
</group>
</form>
Expand Down
17 changes: 11 additions & 6 deletions goods/goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
class goods(models.Model):
_inherit = 'goods'

using_batch = fields.Boolean(u'批次管理')
force_batch_one = fields.Boolean(u'每批次数量为1')
using_batch = fields.Boolean(u'批号管理')
force_batch_one = fields.Boolean(u'每批号数量为1')
attribute_ids = fields.One2many('attribute', 'goods_id', string=u'属性')

def conversion_unit(self, qty):
Expand All @@ -17,6 +17,9 @@ def conversion_unit(self, qty):
def anti_conversion_unit(self, qty):
self.ensure_one()
return self.conversion and qty / self.conversion or 0
# return round(self.conversion and qty / self.conversion or 0,
# self.env['decimal.precision'].precision_get('Goods Quantity'))


class attribute(models.Model):
_name = 'attribute'
Expand All @@ -34,14 +37,16 @@ def _compute_name(self):
class attribute_value(models.Model):
_name = 'attribute.value'
_rec_name = 'value_id'

attribute_id = fields.Many2one('attribute',u'属性')
category_id = fields.Many2one('core.category',u'属性',
domain=[('type','=','attribute')],context={'type':'attribute'}
,required='1')
domain=[('type','=','attribute')],
context={'type':'attribute'}, required='1')
value_id = fields.Many2one('attribute.value.value',u'值',
domain="[('category_id','=',category_id)]",
required='1')


domain="[('category_id','=',category_id)]"
,required='1')
class attribute_value(models.Model):
_name = 'attribute.value.value'
category_id = fields.Many2one('core.category',u'属性',
Expand Down
14 changes: 13 additions & 1 deletion sell/sell.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _get_sell_goods_state(self):
date = fields.Date(u'单据日期', states=READONLY_STATES,
default=lambda self: fields.Date.context_today(self),
select=True, copy=False, help=u"默认是订单创建日期")
delivery_date = fields.Date(u'要求交货日期', states=READONLY_STATES,
delivery_date = fields.Date(u'要求交货日期', states=READONLY_STATES,
default=lambda self: fields.Date.context_today(self),
select=True, copy=False, help=u"订单的要求交货日期")
type = fields.Selection([('sell',u'销货'), ('return', u'退货')], u'类型', default='sell', states=READONLY_STATES)
Expand All @@ -72,10 +72,12 @@ def onchange_discount_rate(self):
if self.discount_rate:
self.discount_amount = total * self.discount_rate * 0.01


@api.model
def create(self, vals):
if vals.get('name', '/') == '/':
vals['name'] = self.env['ir.sequence'].get(self._name) or '/'

return super(sell_order, self).create(vals)

@api.one
Expand Down Expand Up @@ -305,11 +307,21 @@ def onchange_discount_rate(self):
if self.discount_rate:
self.discount_amount = total * self.discount_rate * 0.01

def get_move_origin(self, vals):
print '=' * 10
print self.env.context
return self._name + (self.env.context.get('is_return') and '.return' or '.sell')

@api.model
def create(self, vals):
'''创建销售发货单时生成有序编号'''
if vals.get('name', '/') == '/':
vals['name'] = self.env['ir.sequence'].get(self._name) or '/'

vals.update({
'origin': self.get_move_origin(vals),
})

return super(sell_delivery, self).create(vals)

@api.one
Expand Down
10 changes: 5 additions & 5 deletions warehouse/action/warehouse_action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name='name'>仓库</field>
<field name='res_model'>warehouse</field>
<field name='view_mode'>tree</field>
<field name='domain'>['|', ('active', '!=', 1), ('active', '=', 1)]</field>
<field name='domain'>[('type', '=', 'stock'), '|', ('active', '!=', 1), ('active', '=', 1)]</field>
</record>

<!-- 出入库单 -->
Expand Down Expand Up @@ -102,17 +102,17 @@
<field name='view_id' ref='report_stock_transceive_wizard_form' />
</record>

<!-- 序列号状态表 -->
<!-- 批号状态表 -->
<record id='report_lot_status_action' model='ir.actions.act_window' >
<field name='name'>序列号状态表</field>
<field name='name'>批号状态表</field>
<field name='res_model'>report.lot.status</field>
<field name='view_mode'>graph,tree</field>
<field name='view_id' ref='report_lot_status_graph' />
</record>

<!-- 序列号跟踪表 -->
<!-- 批号跟踪表 -->
<record id='report_lot_track_wizard_action' model='ir.actions.act_window' >
<field name='name'>序列号跟踪表</field>
<field name='name'>批号跟踪表</field>
<field name='res_model'>report.lot.track.wizard</field>
<field name='target'>new</field>
<field name='view_id' ref='report_lot_track_wizard_form' />
Expand Down
8 changes: 4 additions & 4 deletions warehouse/data/sequence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<field name='name'>出库单</field>
<field name='code'>wh.out</field>
<field eval='4' name='padding'/>
<field name='prefix'>WH/OUT/%(y)s%(month)s</field>
<field name='prefix'>OTHERS/OUT/%(y)s%(month)s</field>
</record>

<record id='wh_in_sequence_type' model='ir.sequence.type'>
Expand All @@ -28,7 +28,7 @@
<field name='name'>入库单</field>
<field name='code'>wh.in</field>
<field eval='4' name='padding'/>
<field name='prefix'>WH/IN/%(y)s%(month)s</field>
<field name='prefix'>OTHERS/IN/%(y)s%(month)s</field>
</record>

<record id='wh_internal_sequence_type' model='ir.sequence.type'>
Expand All @@ -40,7 +40,7 @@
<field name='name'>移库单</field>
<field name='code'>wh.internal</field>
<field eval='4' name='padding'/>
<field name='prefix'>WH/INT/%(y)s%(month)s</field>
<field name='prefix'>OTHERS/INT/%(y)s%(month)s</field>
</record>

<record id='wh_inventory_sequence_type' model='ir.sequence.type'>
Expand Down Expand Up @@ -80,4 +80,4 @@
</record>

</data>
</openerp>
</openerp>
2 changes: 1 addition & 1 deletion warehouse/report/lot_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class report_lot_status(models.Model):
goods = fields.Char(u'产品')
uom = fields.Char(u'单位')
uos = fields.Char(u'辅助单位')
lot = fields.Char(u'序列号')
lot = fields.Char(u'批号')
status = fields.Char(u'状态')
warehouse = fields.Char(u'仓库')
date = fields.Date(u'日期')
Expand Down
4 changes: 2 additions & 2 deletions warehouse/report/lot_status_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name='name'>report.lot.status.tree</field>
<field name='model'>report.lot.status</field>
<field name='arch' type='xml'>
<tree string='序列号状态表'>
<tree string='批号状态表'>
<field name='goods' />
<field name='uom' />
<field name='uos' />
Expand All @@ -23,7 +23,7 @@
<field name='name'>report.lot.status.search</field>
<field name='model'>report.lot.status</field>
<field name='arch' type='xml'>
<search string='序列号状态表' >
<search string='批号状态表' >
<field name='goods' string='产品' filter_domain="[('goods', 'ilike', self)]" />
<field name='warehouse' string='仓库' filter_domain="[('warehouse', 'ilike', self)]" />
<field name='uom' string='单位' filter_domain="[('uom', 'ilike', self)]" />
Expand Down
2 changes: 1 addition & 1 deletion warehouse/report/lot_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class report_lot_track(models.Model):
goods = fields.Char(u'产品')
uom = fields.Char(u'单位')
uos = fields.Char(u'辅助单位')
lot = fields.Char(u'序列号')
lot = fields.Char(u'批号')
warehouse = fields.Char(u'仓库')
date = fields.Date(u'日期')
uos_qty = fields.Float(u'辅助数量', digits_compute=dp.get_precision('Goods Quantity'))
Expand Down
4 changes: 2 additions & 2 deletions warehouse/report/lot_track_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name='name'>report.lot.track.tree</field>
<field name='model'>report.lot.track</field>
<field name='arch' type='xml'>
<tree string='序列号状态表'>
<tree string='批号状态表'>
<field name='goods' />
<field name='uom' />
<field name='uos' />
Expand All @@ -23,7 +23,7 @@
<field name='name'>report.lot.track.search</field>
<field name='model'>report.lot.track</field>
<field name='arch' type='xml'>
<search string='序列号状态表' >
<search string='批号状态表' >
<field name='goods' string='产品' filter_domain="[('goods', 'ilike', self)]" />
<field name='warehouse' string='仓库' filter_domain="[('warehouse', 'ilike', self)]" />
<field name='uom' string='单位' filter_domain="[('uom', 'ilike', self)]" />
Expand Down
2 changes: 1 addition & 1 deletion warehouse/report/stock_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class report_stock_balance(models.Model):
goods = fields.Char(u'产品')
uom = fields.Char(u'单位')
uos = fields.Char(u'辅助单位')
lot = fields.Char(u'批次')
lot = fields.Char(u'批号')
warehouse = fields.Char(u'仓库')
goods_qty = fields.Float('数量', digits_compute=dp.get_precision('Goods Quantity'))
goods_uos_qty = fields.Float('辅助单位数量', digits_compute=dp.get_precision('Goods Quantity'))
Expand Down
4 changes: 2 additions & 2 deletions warehouse/report/stock_balance_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
<field name='arch' type='xml'>
<search string='商品库存余额表' >
<field name='goods' string='产品' filter_domain="[('goods', 'ilike', self)]" />
<field name='lot' string='批次' filter_domain="[('lot', 'ilike', self)]" />
<field name='lot' string='批号' filter_domain="[('lot', 'ilike', self)]" />
<field name='warehouse' string='仓库' filter_domain="[('warehouse', 'ilike', self)]" />
<field name='uom' string='单位' filter_domain="[('uom', 'ilike', self)]" />
<field name='uos' string='辅助单位' filter_domain="[('uos', 'ilike', self)]" />

<group expand="0" string="Group By">
<filter string="产品" context="{'group_by':'goods'}"/>
<filter string="批次" context="{'group_by': 'lot'}"/>
<filter string="批号" context="{'group_by': 'lot'}"/>
<filter string="仓库" context="{'group_by': 'warehouse'}"/>
<filter string="单位" context="{'group_by': 'uom'}"/>
<filter string="辅助单位" context="{'group_by': 'uos'}"/>
Expand Down
1 change: 1 addition & 0 deletions warehouse/report/stock_transceive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import openerp.addons.decimal_precision as dp
from openerp import models, fields
import datetime


class report_stock_transceive(models.Model):
Expand Down
5 changes: 5 additions & 0 deletions warehouse/report/stock_transceive_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class report_stock_transceive_collect(models.Model):
'wh.out.losses': 'losses_out',
'wh.in.overage': 'overage_in',

'buy.receipt.sell': u'purchase_in',
'buy.receipt.return': u'purchase_out',
'sell.delivery.sell': u'sale_out',
'sell.delivery.return': u'sale_in',

('wh.assembly', True): 'assembly_out',
('wh.assembly', False): 'assembly_in',

Expand Down
2 changes: 1 addition & 1 deletion warehouse/view/production_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<tree string='库存调拨' editable='bottom'>
<field name='goods_id' required='1' />
<field name='uom_id' required='1' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' required='1' />
<field name='using_batch' invisible='1' />
<field name='force_batch_one' invisible='1' />

Expand Down
8 changes: 4 additions & 4 deletions warehouse/view/warehouse_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<field name='move_id' string='单据编号' />
<field name='goods_id' />
<field name='uom_id' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' required='1' />
<field name='goods_uos_qty' sum='1' groups='goods.auxiliary_unit_groups' />
<field name='goods_qty' sum='1' />
<field name='warehouse_id' />
Expand All @@ -68,7 +68,7 @@
<field name='using_batch' invisible='1' />
<field name='force_batch_one' invisible='1' />
<field name='uom_id' required='1' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' required='1' />
<field name='lot_qty' invisible='1' />
<field name='lot_uos_qty' invisible='1' />
<field name='lot_id' attrs="{'readonly': [('using_batch', '=', False)], 'required': [('using_batch', '=', True)]}" domain="[('goods_id', '=', goods_id), ('state', '=', 'done'), ('lot', '!=', False), ('qty_remaining', '>', 0), ('warehouse_dest_id', '=', warehouse_id)]" context="{'lot': True}" options="{'no_open': True, 'no_create': True}" />
Expand All @@ -91,7 +91,7 @@
<tree string='库存调拨' editable='bottom'>
<field name='goods_id' required='1' />
<field name='uom_id' required='1' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' required='1' />
<field name='using_batch' invisible='1' />
<field name='force_batch_one' invisible='1' />

Expand All @@ -117,7 +117,7 @@
<field name='using_batch' invisible='1' />
<field name='force_batch_one' invisible='1' />
<field name='uom_id' required='1' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' />
<field name='uos_id' groups='goods.auxiliary_unit_groups' required='1' />
<field name='lot' invisible='1' />
<field name='lot_id' attrs="{'readonly': [('using_batch', '=', False)], 'required': [('using_batch', '=', True)]}" domain="[('goods_id', '=', goods_id), ('state', '=', 'done'), ('lot', '!=', False), ('qty_remaining', '>', 0)]" context="{'lot': True}" options="{'no_open': True, 'no_create': True}" />

Expand Down

0 comments on commit 7ffdb27

Please sign in to comment.