Skip to content

Commit

Permalink
[10.0] purchase_fop_shipping: fixes and improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Pigeon committed Jun 7, 2017
1 parent 2f8e575 commit 536e686
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
5 changes: 0 additions & 5 deletions purchase_fop_shipping/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ Usage
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
Known issues / Roadmap
======================

* ...

Bug Tracker
===========

Expand Down
Empty file modified purchase_fop_shipping/__init__.py
100755 → 100644
Empty file.
8 changes: 5 additions & 3 deletions purchase_fop_shipping/__manifest__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
'category': 'Purchase',
'depends': ['purchase'],
'website': 'http://www.akretion.com/',
'data': ['views/purchase_view.xml',
'views/partner_view.xml',
],
'data': [
'security/purchase_group.xml',
'views/purchase_view.xml',
'views/partner_view.xml',
],
'installable': True,
}
Empty file modified purchase_fop_shipping/models/__init__.py
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion purchase_fop_shipping/models/partner.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ class ResPartner(models.Model):
_inherit = 'res.partner'

fop_shipping = fields.Float(
'FOP shipping', help='Min purchase order amount for FOP shipping',)
'FOP shipping', help='Min purchase order amount for FOP shipping',
company_dependent=True)
6 changes: 4 additions & 2 deletions purchase_fop_shipping/models/purchase.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ class PurchaseOrder(models.Model):
fop_reached = fields.Boolean(
string='FOP reached',
help='Free-Of-Payment shipping reached',
compute='_fop_shipping_reached')
compute_sudo=False,
compute='_compute_fop_shipping_reached')
force_order_under_fop = fields.Boolean(
string='Confirm under FOP',
help='Force confirm purchase order under Free-Of-Payment shipping',)
fop_shipping = fields.Float(
'FOP shipping',
related='partner_id.fop_shipping',
related_sudo=False,
readonly=True,
help='Min purchase order amount for Free-Of-Payment shipping',)

@api.multi
@api.depends('amount_total', 'partner_id.fop_shipping')
def _fop_shipping_reached(self):
def _compute_fop_shipping_reached(self):
for record in self:
record.fop_reached = record.amount_total >\
record.partner_id.fop_shipping
Expand Down
18 changes: 17 additions & 1 deletion purchase_fop_shipping/views/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="inherit_id" ref="purchase.purchase_order_tree" />
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="colors">red:fop_reached ==
<attribute translation="off" name="colors">red:fop_reached ==
False;blue:fop_reached == True;grey:state=='cancel'
</attribute>
</xpath>
Expand All @@ -17,6 +17,22 @@
</field>
</record>

<record id="purchase_order_form_inherit_purchase_fop_shipping"
model="ir.ui.view">
<field name="name">purchase.order.form.inherit.purchase.fop.shipping</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="amount_total" position="after">
<field name="fop_shipping"
readonly="1"
attrs="{'invisible':[('fop_shipping', '=', 0)]}"
widget="monetary"
options="{'currency_field': 'currency_id'}"/>
</field>
</field>
</record>

<record model="ir.ui.view" id="purchase_order_delivery_paid_form_view_inherit">
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
Expand Down

0 comments on commit 536e686

Please sign in to comment.