Browse Source

[CHANGE][0045 - Date de livraison dans le bon de commande]

Remove date_planned and button to set date in tab delivery
Add a new field manual_date_planned
Onchange on order_line to set the first time a date planned
Force the manual_date_planned to all line at confirmation
Change the report for purchase order
[ADD] default value on picking responsible: set the create_uid as responsible (this mean the one that confirm the purchase order
pull/56/head
Thibault Francois 6 years ago
parent
commit
14e110689d
  1. 2
      beesdoo_inventory/models/stock.py
  2. 3
      beesdoo_purchase/__init__.py
  3. 5
      beesdoo_purchase/models/purchase.py
  4. 3
      beesdoo_purchase/views/purchase_order.xml
  5. 2
      beesdoo_purchase_manual_date_planned/__init__.py
  6. 31
      beesdoo_purchase_manual_date_planned/__openerp__.py
  7. 0
      beesdoo_purchase_manual_date_planned/models/__init__.py
  8. 28
      beesdoo_purchase_manual_date_planned/models/purchase.py
  9. 18
      beesdoo_purchase_manual_date_planned/report/report_purchaseorder.xml
  10. 23
      beesdoo_purchase_manual_date_planned/views/purchase_order.xml

2
beesdoo_inventory/models/stock.py

@ -5,7 +5,7 @@ class StockPicking(models.Model):
_inherit = 'stock.picking'
max_shipping_date = fields.Datetime("End Shipping Date")
responsible = fields.Many2one('res.partner', string="Responsible")
responsible = fields.Many2one('res.partner', string="Responsible", default=lambda self: self.env.user.partner_id.id)
def _add_follower(self):
if(self.responsible):

3
beesdoo_purchase/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
import models
# -*- coding: utf-8 -*-

5
beesdoo_purchase/models/purchase.py

@ -1,5 +0,0 @@
# -*- coding: utf-8 -*-
from openerp import models, api
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'

3
beesdoo_purchase/views/purchase_order.xml

@ -8,9 +8,6 @@
<field name="product_id" position="attributes">
<attribute name="domain">[('main_seller_id','=', parent.partner_id)]</attribute>
</field>
<xpath expr="//page/group/group//field[@name='date_planned']" position="attributes">
<attribute name="readonly">0</attribute>
</xpath>
</field>
</record>
</data>

2
beesdoo_purchase_manual_date_planned/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import models

31
beesdoo_purchase_manual_date_planned/__openerp__.py

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
{
'name': "Bees Purchase Manual date planned",
'summary': """
Extension du module Purchase to set manually the date planned for the whole purchase.order""",
'description': """
Long description of module's purpose
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'Purchase',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['purchase'],
# always loaded
'data': [
'views/purchase_order.xml',
'report/report_purchaseorder.xml',
],
# only loaded in demonstration mode
'demo': [],
}

0
beesdoo_purchase/models/__init__.py → beesdoo_purchase_manual_date_planned/models/__init__.py

28
beesdoo_purchase_manual_date_planned/models/purchase.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
from openerp import models, api, fields
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
manual_date_planned = fields.Datetime(string='Scheduled Date', required=True)
@api.onchange('order_line', 'order_line.date_planned')
def _on_change_manual_date_planned(self):
"""
Since we don't see the date planned on the line anymore
give an idea of the user by setting the first date planned of the lines
"""
for line in self.order_line:
if line.date_planned and not self.manual_date_planned:
self.manual_date_planned = line.date_planned
break;
@api.multi
def button_confirm(self):
"""
Since we hide the button to set the date planned on all line and we
hide them, we call the method to set the date planned on the line at the confirmation
"""
self.ensure_one()
self.with_context(date_planned=self.manual_date_planned).action_set_date_planned()
return super(PurchaseOrder, self).button_confirm()

18
beesdoo_purchase_manual_date_planned/report/report_purchaseorder.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_purchaseorder_document" inherit_id="purchase.report_purchaseorder_document" name="beesdoo purchaseorder">
<div t-if="o.date_order" position="after">
<div class="col-xs-3">
<strong>Date Planned:</strong>
<div t-field="o.date_planned" />
</div>
</div>
<xpath expr="//span[@t-field='line.date_planned']/.." position="attributes">
<attribute name="style">display:none;</attribute>
</xpath>
</template>
</data>
</odoo>

23
beesdoo_purchase_manual_date_planned/views/purchase_order.xml

@ -0,0 +1,23 @@
<openerp>
<data>
<record model="ir.ui.view" id="beesdoo_purchase_order_form_view">
<field name="name">beesdoo.purchase.order.form.view</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='date_planned']/../../div" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//label[@for='date_planned']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//tree/field[@name='date_planned']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<field name="date_order" position="after">
<field name="manual_date_planned" attrs="{'readonly': [('state', 'not in', ('draft', 'sent'))]}" />
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save