Skip to content

Commit

Permalink
Merge 102980a into 8c5bcff
Browse files Browse the repository at this point in the history
  • Loading branch information
yvaucher committed May 8, 2015
2 parents 8c5bcff + 102980a commit e53bd69
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 14 deletions.
31 changes: 28 additions & 3 deletions logistic_order/i18n/logistic_order.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-04-13 12:09+0000\n"
"PO-Revision-Date: 2015-04-13 12:09+0000\n"
"POT-Creation-Date: 2015-05-05 12:12+0000\n"
"PO-Revision-Date: 2015-05-05 12:12+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -86,7 +86,7 @@ msgid "INCOTERMS 2010"
msgstr ""

#. module: logistic_order
#: code:addons/logistic_order/model/sale_order.py:125
#: code:addons/logistic_order/model/sale_order.py:151
#, python-format
msgid "If this is not only for Cost Estimate, you must provide a Consignee"
msgstr ""
Expand Down Expand Up @@ -169,6 +169,11 @@ msgstr ""
msgid "Sales Order"
msgstr ""

#. module: logistic_order
#: model:ir.model,name:logistic_order.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: logistic_order
#: view:sale.order:logistic_order.view_sales_order_filter
msgid "Search Order"
Expand All @@ -189,6 +194,11 @@ msgstr ""
msgid "The pricing indications in this estimate are valid till:"
msgstr ""

#. module: logistic_order
#: help:sale.order.line,value_of_goods:0
msgid "This field represent the value of the goods and will be used for reporting purpose (e.g mobilization table)"
msgstr ""

#. module: logistic_order
#: view:website:sale.report_saleorder_document
msgid "Total volume (m³)"
Expand Down Expand Up @@ -219,11 +229,21 @@ msgstr ""
msgid "Validity:"
msgstr ""

#. module: logistic_order
#: field:sale.order.line,value_of_goods:0
msgid "Value of goods"
msgstr ""

#. module: logistic_order
#: view:website:sale.report_saleorder_document
msgid "Volume"
msgstr ""

#. module: logistic_order
#: field:sale.order,volume:0
msgid "Volume (m³)"
msgstr ""

#. module: logistic_order
#: view:website:sale.report_saleorder_document
msgid "Volume per unit (m³)"
Expand All @@ -234,6 +254,11 @@ msgstr ""
msgid "Weight"
msgstr ""

#. module: logistic_order
#: field:sale.order,weight:0
msgid "Weight (kg)"
msgstr ""

#. module: logistic_order
#: view:website:sale.report_saleorder_document
msgid "Weight per unit (kg)"
Expand Down
35 changes: 35 additions & 0 deletions logistic_order/model/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ class SaleOrderLine(models.Model):
compute='_get_weight',
)

# This field is hidden in logistic_order module but is required
# in logistic_order_donation and logistic_requistiion
value_of_goods = fields.Float(
help="This field represent the value of the goods and will be used for"
" reporting purpose (e.g mobilization table)")

@api.one
@api.depends('product_id.volume', 'product_uom_qty')
def _get_volume(self):
Expand All @@ -185,6 +191,35 @@ def _get_volume(self):
def _get_weight(self):
self.weight = self.product_id.weight * self.product_uom_qty

def product_id_change_with_wh(self, cr, uid, ids,
pricelist, product,
qty=0,
uom=False,
qty_uos=0,
uos=False,
name='',
partner_id=False,
lang=False,
update_tax=True,
date_order=False,
packaging=False,
fiscal_position=False,
flag=False,
warehouse_id=False,
context=None):
res = super(SaleOrderLine, self).product_id_change_with_wh(
cr, uid, ids,
pricelist, product, qty, uom,
qty_uos, uos, name, partner_id,
lang, update_tax, date_order,
packaging, fiscal_position, flag,
warehouse_id,
context=context)

if 'price_unit' in res.get('value', {}):
res['value']['value_of_goods'] = res['value']['price_unit']
return res


class mail_compose_message(models.Model):
_inherit = 'mail.compose.message'
Expand Down
5 changes: 5 additions & 0 deletions logistic_order/view/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
<field name="weight"/>
</xpath>

<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']"
position="after">
<field name="value_of_goods" invisible="1"/>
</xpath>

<!-- hide taxes -->
<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form//field[@name='tax_id']" position="attributes">
<attribute name="invisible" eval="1"/>
Expand Down
8 changes: 8 additions & 0 deletions logistic_order_donation/model/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ def product_id_change_with_wh(self, cr, uid, ids,
res['warning']['message'] = warning
else:
del res['warning']

if 'price_unit' in res.get('value', {}):
if context.get('order_type') == 'donation':
product_model = self.pool['product.product']
product = product_model.browse(cr, uid, product,
context=context)
if product.type != 'service':
res['value']['price_unit'] = 0.0
return res
12 changes: 8 additions & 4 deletions logistic_order_donation/view/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,26 @@
<xpath
expr="//field[@name='order_line']/form//field[@name='product_id']"
position="attributes">
<attribute name='context_ikd'>{'order_type': order_type}</attribute>
<attribute name='context_ikd'>{'order_type': parent.order_type}</attribute>
</xpath>
<xpath
expr="//field[@name='order_line']/tree//field[@name='product_id']"
position="attributes">
<attribute name='context_ikd'>{'order_type': order_type}</attribute>
<attribute name='context_ikd'>{'order_type': parent.order_type}</attribute>
</xpath>
<xpath
expr="//field[@name='order_line']/tree//field[@name='product_uom_qty']"
position="attributes">
<attribute name='context_ikd'>{'order_type': order_type}</attribute>
<attribute name='context_ikd'>{'order_type': parent.order_type}</attribute>
</xpath>
<xpath
expr="//field[@name='order_line']/form//field[@name='product_uos_qty']"
position="attributes">
<attribute name='context_ikd'>{'order_type': order_type}</attribute>
<attribute name='context_ikd'>{'order_type': parent.order_type}</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/form//field[@name='value_of_goods']"
position="attributes">
<attribute name="invisible"/>
</xpath>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion logistic_order_requisition_donation/view/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<record id="view_order_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="logistic_requisition.view_order_form1"/>
<field name="inherit_id" ref="logistic_requisition.view_order_form3"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']" position="attributes">
<attribute name="context_link_ikd_req">{'default_order_type': order_type}</attribute>
Expand Down
1 change: 1 addition & 0 deletions logistic_requisition/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"purchase_requisition_transport_document",
"purchase_requisition_transport_multi_address",
"sale_transport_multi_address",
"web_context_tunnel",
],
"demo": ['data/logistic_requisition_demo.xml'],
"data": ["wizard/assign_line_view.xml",
Expand Down
41 changes: 41 additions & 0 deletions logistic_requisition/model/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class SaleOrderLine(models.Model):
lr_source_id = fields.Many2one(
'logistic.requisition.source',
'Logistics Requisition Source',
readonly=True,
)
sourcing_method = fields.Selection(
related='lr_source_id.sourcing_method',
Expand All @@ -217,3 +218,43 @@ class SaleOrderLine(models.Model):
sourced_by = fields.Many2one(
domain="[('product_id', '=', product_id),"
" ('order_id.state', 'in', ['draftpo', 'confirmed'])]")

def product_id_change_with_wh(self, cr, uid, ids,
pricelist, product,
qty=0,
uom=False,
qty_uos=0,
uos=False,
name='',
partner_id=False,
lang=False,
update_tax=True,
date_order=False,
packaging=False,
fiscal_position=False,
flag=False,
warehouse_id=False,
context=None):
res = super(SaleOrderLine, self).product_id_change_with_wh(
cr, uid, ids,
pricelist, product, qty, uom,
qty_uos, uos, name, partner_id,
lang, update_tax, date_order,
packaging, fiscal_position, flag,
warehouse_id,
context=context)

if 'price_unit' in res.get('value', {}):
# warehouse dispatch must be only a transfert of good value
# for products, we still want to charge services
if context.get('sourcing_method') == 'wh_dispatch':
product_model = self.pool['product.product']
product = product_model.browse(cr, uid, product,
context=context)
if product.type != 'service':
source_id = context.get('lr_source_id')
source = self.pool['logistic.requisition.source'].browse(
cr, uid, source_id, context=context)
if source.requisition_id.requisition_type == 'donor_stock':
res['value']['price_unit'] = 0.0
return res
23 changes: 19 additions & 4 deletions logistic_requisition/view/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@
position="after">
<field name="price_is"/>
</xpath>
<xpath expr="//field[@name='order_line']/form//field[@name='delay']" position="after">
<field name="lr_source_id" groups="base.group_no_one"/>
<field name="sourcing_method"/>
</xpath>
<xpath expr="//field[@name='order_line']/form//field[@name='manually_sourced']" position="attributes">
<attribute name="attrs">{'invisible': [('sourcing_method', 'not in', ['procurement', 'fw_agreement', 'reuse_bid', 'other'])], 'invisible': [('sourcing_method', 'in', ['procurement', 'fw_agreement', 'reuse_bid'])]}</attribute>
</xpath>
Expand Down Expand Up @@ -92,6 +88,25 @@
<xpath expr="//field[@name='order_line']/form//field[@name='stock_owner_id']" position="attributes">
<attribute name="attrs">{'invisible': [('sourcing_method', 'not in', ['wh_dispatch', 'other'])]}</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/form//field[@name='delay']/.." position="after">
<field name="lr_source_id"/>
<field name="sourcing_method"/>
</xpath>
<xpath expr="//field[@name='order_line']/form//field[@name='product_id']" position="attributes">
<attribute name="context_sourcing">{'sourcing_method': sourcing_method, 'lr_source_id': lr_source_id}</attribute>
</xpath>
</field>
</record>

<record id="view_order_form4" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="logistic_order.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/form//field[@name='value_of_goods']"
position="attributes">
<attribute name="invisible"/>
</xpath>
</field>
</record>

Expand Down
13 changes: 11 additions & 2 deletions logistic_requisition/wizard/cost_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,17 @@ def _is_manually_source(self, sourcing):
@api.model
def _prepare_cost_estimate_line(self, sourcing):
sale_line_obj = self.env['sale.order.line']
if (sourcing.requisition_id.requisition_type == 'donor_stock' and
sourcing.sourcing_method == 'wh_dispatch' and
sourcing.proposed_product_id.type != 'service'):
product_price = 0.0
else:
product_price = sourcing.unit_cost
vals = {'product_id': sourcing.proposed_product_id.id,
'name': sourcing.requisition_line_id.description,
'lr_source_id': sourcing.id,
'price_unit': sourcing.unit_cost,
'price_unit': product_price,
'value_of_goods': sourcing.unit_cost,
'price_is': sourcing.price_is,
'product_uom_qty': sourcing.proposed_qty,
'product_uom': sourcing.proposed_uom_id.id,
Expand All @@ -144,9 +151,11 @@ def _prepare_cost_estimate_line(self, sourcing):
partner_id=requisition.partner_id.id,
qty=sourcing.proposed_qty,
uom=sourcing.proposed_uom_id.id).get('value', {})
# price_unit and type of the requisition line must be kept
# price_unit and value of goods of the requisition source must be kept
if 'price_unit' in onchange_vals:
del onchange_vals['price_unit']
if 'value_of_goods' in onchange_vals:
del onchange_vals['value_of_goods']
vals.update(onchange_vals)
return vals

Expand Down

0 comments on commit e53bd69

Please sign in to comment.