mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 20:52:07 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import confirm_expiry
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class ConfirmExpiry(models.TransientModel):
|
||||
_name = 'expiry.picking.confirmation'
|
||||
_description = 'Confirm Expiry'
|
||||
|
||||
lot_ids = fields.Many2many('stock.lot', readonly=True, required=True)
|
||||
picking_ids = fields.Many2many('stock.picking', readonly=True)
|
||||
description = fields.Char('Description', compute='_compute_descriptive_fields')
|
||||
show_lots = fields.Boolean('Show Lots', compute='_compute_descriptive_fields')
|
||||
|
||||
@api.depends('lot_ids')
|
||||
def _compute_descriptive_fields(self):
|
||||
# Shows expired lots only if we are more than one expired lot.
|
||||
self.show_lots = len(self.lot_ids) > 1
|
||||
if self.show_lots:
|
||||
# For multiple expired lots, they are listed in the wizard view.
|
||||
self.description = _(
|
||||
"You are going to deliver some product expired lots."
|
||||
"\nDo you confirm you want to proceed ?"
|
||||
)
|
||||
else:
|
||||
# For one expired lot, its name is written in the wizard message.
|
||||
self.description = _(
|
||||
"You are going to deliver the product %(product_name)s, %(lot_name)s which is expired."
|
||||
"\nDo you confirm you want to proceed ?",
|
||||
product_name=self.lot_ids.product_id.display_name,
|
||||
lot_name=self.lot_ids.name
|
||||
)
|
||||
|
||||
def process(self):
|
||||
picking_to_validate = self.env.context.get('button_validate_picking_ids')
|
||||
if picking_to_validate:
|
||||
picking_to_validate = self.env['stock.picking'].browse(picking_to_validate)
|
||||
ctx = dict(self.env.context, skip_expired=True)
|
||||
ctx.pop('default_lot_ids')
|
||||
return picking_to_validate.with_context(ctx).button_validate()
|
||||
return True
|
||||
|
||||
def process_no_expired(self):
|
||||
""" Don't process for concerned pickings (ones with expired lots), but
|
||||
process for all other pickings (in case of multi). """
|
||||
# Remove `self.pick_ids` from `button_validate_picking_ids` and call
|
||||
# `button_validate` with the subset (if any).
|
||||
pickings_to_validate = self.env['stock.picking'].browse(self.env.context.get('button_validate_picking_ids'))
|
||||
pickings_to_validate = pickings_to_validate - self.picking_ids
|
||||
if pickings_to_validate:
|
||||
return pickings_to_validate.with_context(skip_expired=True).button_validate()
|
||||
return True
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="confirm_expiry_view" model="ir.ui.view">
|
||||
<field name="name">Confirm</field>
|
||||
<field name="model">expiry.picking.confirmation</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Confirmation">
|
||||
<p>
|
||||
<field name="description"/>
|
||||
</p>
|
||||
<field name="show_lots" invisible="1"/>
|
||||
<field name="lot_ids" attrs="{'invisible': [('show_lots', '=', False)]}">
|
||||
<tree string="Expired Lot(s)">
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
<footer>
|
||||
<button name="process"
|
||||
string="Confirm"
|
||||
type="object"
|
||||
data-hotkey="q"
|
||||
class="btn-primary"/>
|
||||
<button name="process_no_expired"
|
||||
string="Proceed except for expired one"
|
||||
type="object"
|
||||
data-hotkey="w"
|
||||
class="btn-secondary"/>
|
||||
<button string="Discard"
|
||||
class="btn-secondary"
|
||||
special="cancel" data-hotkey="z"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue