diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 13:53:28 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 13:53:28 +0700 |
| commit | 63433ff471ba98e6fc63bca16abd9a585471498b (patch) | |
| tree | 7fe83758b1c40888bab68f5498e4a1c7da4d7891 /indoteknik_custom/models/stock_immediate_transfer.py | |
| parent | ff20b62d6932c6be4ffb56f63f3c05be3aa72c06 (diff) | |
| parent | e3521c2153c36cee6629cee9146e1b4b0201da9f (diff) | |
Merge branch 'odoo-production' into CR/form-merchant
# Conflicts:
# indoteknik_api/models/res_partner.py
# indoteknik_api/models/res_users.py
# indoteknik_custom/__manifest__.py
# indoteknik_custom/models/__init__.py
# indoteknik_custom/models/res_partner.py
# indoteknik_custom/security/ir.model.access.csv
# indoteknik_custom/views/res_partner.xml
# indoteknik_custom/views/user_company_request.xml
Diffstat (limited to 'indoteknik_custom/models/stock_immediate_transfer.py')
| -rw-r--r-- | indoteknik_custom/models/stock_immediate_transfer.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_immediate_transfer.py b/indoteknik_custom/models/stock_immediate_transfer.py new file mode 100644 index 00000000..4be0dff2 --- /dev/null +++ b/indoteknik_custom/models/stock_immediate_transfer.py @@ -0,0 +1,36 @@ +from odoo import models, api, _ +from odoo.exceptions import UserError + +class StockImmediateTransfer(models.TransientModel): + _inherit = 'stock.immediate.transfer' + + def process(self): + """Override process method to add send_mail_bills logic.""" + pickings_to_do = self.env['stock.picking'] + pickings_not_to_do = self.env['stock.picking'] + + for line in self.immediate_transfer_line_ids: + if line.to_immediate is True: + pickings_to_do |= line.picking_id + else: + pickings_not_to_do |= line.picking_id + + for picking in pickings_to_do: + picking.send_mail_bills() + # If still in draft => confirm and assign + if picking.state == 'draft': + picking.action_confirm() + if picking.state != 'assigned': + picking.action_assign() + if picking.state != 'assigned': + raise UserError(_("Could not reserve all requested products. Please use the 'Mark as Todo' button to handle the reservation manually.")) + for move in picking.move_lines.filtered(lambda m: m.state not in ['done', 'cancel']): + for move_line in move.move_line_ids: + move_line.qty_done = move_line.product_uom_qty + + pickings_to_validate = self.env.context.get('button_validate_picking_ids') + if pickings_to_validate: + pickings_to_validate = self.env['stock.picking'].browse(pickings_to_validate) + pickings_to_validate = pickings_to_validate - pickings_not_to_do + return pickings_to_validate.with_context(skip_immediate=True).button_validate() + return True |
