1- # (Odoo manifest dictionary removed from Python file. Place it in __manifest__.py instead.)
1+ """
2+ Odoo manifest dictionary has been removed from this Python file.
3+ Please place the manifest dictionary in a separate __manifest__.py file as required by Odoo module structure.
4+ """
25from odoo import fields , models , api , _
36from odoo .exceptions import ValidationError , AccessError
47from odoo import http
58from odoo .http import request
69
10+ # Constant for the pickup request form field name
11+ PICKUP_ITEM_IDS_FIELD = 'item_ids'
12+
713class StockProductionLot (models .Model ):
814 _inherit = 'stock.production.lot'
915
@@ -12,7 +18,7 @@ class StockProductionLot(models.Model):
1218
1319class ShreddingService (models .Model ):
1420 _name = 'shredding.service'
15- _description = 'Document Shredding Service'
21+ service_date = fields . Date ( string = ' Service Date' , default = lambda self : fields . Date . today ())
1622
1723 customer_id = fields .Many2one ('res.partner' , string = 'Customer' , required = True )
1824 service_date = fields .Date (string = 'Service Date' , default = fields .Date .today )
@@ -27,7 +33,7 @@ class ShreddingService(models.Model):
2733 domain = [('customer_id' , '!=' , False )])
2834 audit_barcodes = fields .Text (string = 'Audit Barcodes' )
2935 total_charge = fields .Float (string = 'Total Charge' , compute = '_compute_total_charge' )
30- timestamp = fields .Datetime (string = 'Service Timestamp' , default = fields .Datetime .now )
36+ timestamp = fields .Datetime (string = 'Service Timestamp' , default = lambda self : fields .Datetime .now () )
3137 latitude = fields .Float (string = 'Latitude' )
3238 longitude = fields .Float (string = 'Longitude' )
3339 attachment_ids = fields .Many2many ('ir.attachment' , string = 'Attachments' )
@@ -59,7 +65,10 @@ def _compute_total_charge(self):
5965 if record .service_type == 'bin' :
6066 record .total_charge = len (record .bin_ids ) * 10.0
6167 else :
62- qty = record .box_quantity or len (record .shredded_box_ids ) or 0
68+ if record .box_quantity is not None :
69+ qty = record .box_quantity
70+ else :
71+ qty = len (record .shredded_box_ids ) or 0
6372 record .total_charge = qty * 5.0
6473
6574 @api .depends ('latitude' , 'longitude' )
@@ -90,8 +99,11 @@ class PickupRequest(models.Model):
9099 request_date = fields .Date (string = 'Request Date' , default = fields .Date .today )
91100 state = fields .Selection ([
92101 ('draft' , 'Draft' ),
93- ('confirmed' , 'Confirmed' ),
94- ('done' , 'Done' )
102+ item_ids = fields .Many2many (
103+ 'stock.production.lot' ,
104+ string = 'Items' ,
105+ domain = lambda self : [('customer_id' , '=' , self .customer_id .id )] if self .customer_id else []
106+ )
95107 ], default = 'draft' , string = 'Status' )
96108 item_ids = fields .Many2many ('stock.production.lot' , string = 'Items' ,
97109 domain = "[('customer_id', '=', customer_id)]" )
@@ -180,7 +192,7 @@ def request_pickup(self, **post):
180192 if request .httprequest .method == 'POST' :
181193 try :
182194 # Sanitize and validate item_ids
183- raw_ids = request .httprequest .form .getlist ('item_ids' )
195+ raw_ids = request .httprequest .form .getlist (PICKUP_ITEM_IDS_FIELD )
184196 item_ids = [int (id ) for id in raw_ids if id .isdigit ()]
185197 if not item_ids :
186198 error = _ ("Please select at least one item for pickup." )
@@ -195,6 +207,11 @@ def request_pickup(self, **post):
195207 'serials' : serials ,
196208 'error' : error
197209 })
210+ serials = self ._get_serials (partner )
211+ return request .render ('records_management.pickup_request_form' , {
212+ 'serials' : serials ,
213+ 'error' : error
214+ })
198215
199216# --- Placeholders for test coverage (to be implemented in test modules) ---
200217# def test_compute_total_charge(self): ...
0 commit comments