finalization of the purchase_suggest_supplierinfo_on_product module

This commit is contained in:
chafique-delli
2016-07-04 17:41:07 +02:00
parent 6576cbaf19
commit ee91b30fc6
6 changed files with 117 additions and 18 deletions

View File

@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Chafique DELLI @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import purchase_suggest

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Chafique DELLI @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api, _
@@ -15,6 +17,7 @@ class PurchaseSuggestionGenerate(models.TransientModel):
sline = super(PurchaseSuggestionGenerate, self)._prepare_suggest_line(
product_id, qty_dict)
sline['company_id'] = self.env.user.company_id.id
sline['qty_to_order'] = 0.0
if sline['seller_id'] not in self.seller_ids.ids:
product = self.env['product.product'].browse(sline['product_id'])
for supplierinfo in product.seller_ids:
@@ -102,11 +105,13 @@ class PurchaseSuggest(models.TransientModel):
@api.multi
def write(self, vals):
vals['qty_to_order'] = 0.0
#vals['qty_to_order'] = 0.0
if 'draft_po_qty' in vals:
if vals['draft_po_qty'] > self.draft_po_qty:
vals['qty_to_order'] = vals['draft_po_qty'] - self.draft_po_qty
else:
raise Warning(_("La nouvelle quantité sur la commande ne peut pas être inférieure à l'anciennne quantité"))
raise Warning(_('The new quantity for the existing '
'purchase order line can not be less than '
'the old quantity'))
super(PurchaseSuggest, self).write(vals)
return True

View File

@@ -19,5 +19,24 @@
</field>
</record>
<record id="purchase_suggest_generate_form" model="ir.ui.view">
<field name="model">purchase.suggest.generate</field>
<field name="inherit_id" ref="purchase_suggest.purchase_suggest_generate_form"/>
<field name="arch" type="xml">
<xpath expr="//form[@string='Generate Purchase Suggestions']/ol" position="replace">
<ol>
<li>it will search all the products linked to the selected stock location and suppliers, limited to the product categories if some were selected</li>
<li>if found product then it will create a purchase suggestion line</li>
</ol>
</xpath>
<xpath expr="//form[@string='Generate Purchase Suggestions']/p[2]" position="replace">
<p>The purchase suggestion lines display as much information as possible to help you take the decision on the quantity that you would like to re-order. When you have decided the quantity you want to re-order, add the quantity at the value in the Draft PO Quantity column.</p>
</xpath>
<xpath expr="//form[@string='Generate Purchase Suggestions']/p[3]" position="replace">
<p>Once you have changed the Draft PO Quantity for all the lines you would like to re-order, select this lines and click on <i>More</i> > <i>Create Purchase Orders</i></p>
</xpath>
</field>
</record>
</data>
</openerp>